multianime (not done)

This commit is contained in:
LagradOst 2022-04-07 15:54:55 +02:00
parent 3db8864e7c
commit ca8b1293bb
3 changed files with 66 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.lagradost.cloudstream3.animeproviders.*
import com.lagradost.cloudstream3.metaproviders.CrossTmdbProvider
import com.lagradost.cloudstream3.metaproviders.MultiAnimeProvider
import com.lagradost.cloudstream3.movieproviders.*
import com.lagradost.cloudstream3.syncproviders.OAuth2API.Companion.aniListApi
import com.lagradost.cloudstream3.syncproviders.OAuth2API.Companion.malApi
@ -103,6 +104,7 @@ object APIHolder {
DubbedAnimeProvider(),
MonoschinosProvider(),
KawaiifuProvider(), // disabled due to cloudflare
//MultiAnimeProvider(),
)
}
@ -268,7 +270,8 @@ object APIHolder {
} else {
// Filter API depending on preferred media type
val listEnumAnime = listOf(TvType.Anime, TvType.AnimeMovie, TvType.OVA)
val listEnumMovieTv = listOf(TvType.Movie, TvType.TvSeries, TvType.Cartoon, TvType.AsianDrama)
val listEnumMovieTv =
listOf(TvType.Movie, TvType.TvSeries, TvType.Cartoon, TvType.AsianDrama)
val listEnumDoc = listOf(TvType.Documentary)
val mediaTypeList = when (currentPrefMedia) {
2 -> listEnumAnime
@ -741,7 +744,7 @@ interface LoadResponse {
this.syncData[aniListIdPrefix] = (id ?: return).toString()
}
fun LoadResponse.addImdbUrl(url : String?) {
fun LoadResponse.addImdbUrl(url: String?) {
addImdbId(imdbUrlToIdNullable(url))
}

View File

@ -0,0 +1,44 @@
package com.lagradost.cloudstream3.metaproviders
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
import com.lagradost.cloudstream3.syncproviders.OAuth2API
class MultiAnimeProvider : MainAPI() {
override var name = "MultiAnime"
override val lang = "en"
override val usesWebView = true
override val supportedTypes = setOf(TvType.Anime)
private val syncApi = OAuth2API.aniListApi
private val validApis by lazy {
APIHolder.apis.filter {
it.lang == this.lang && it::class.java != this::class.java && it.supportedTypes.contains(
TvType.Anime
)
}
}
private fun filterName(name: String): String {
return Regex("""[^a-zA-Z0-9-]""").replace(name, "")
}
override suspend fun search(query: String): List<SearchResponse>? {
return syncApi.search(query)?.map {
AnimeSearchResponse(it.name, it.url, this.name, TvType.Anime, it.posterUrl)
}
}
override suspend fun load(url: String): LoadResponse? {
return syncApi.getResult(url)?.let { res ->
newAnimeLoadResponse(res.title!!, url, TvType.Anime) {
posterUrl = res.posterUrl
plot = res.synopsis
tags = res.genres
rating = res.publicScore
trailerUrl = res.trailerUrl
addAniListId(res.id.toIntOrNull())
}
}
}
}

View File

@ -84,7 +84,8 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
}
override suspend fun getResult(id: String): SyncAPI.SyncResult? {
val internalId = id.toIntOrNull() ?: return null
val internalId = (Regex("anilist\\.co/anime/(\\d*)").find(id)?.groupValues?.getOrNull(1)
?: id).toIntOrNull() ?: return null
val season = getSeason(internalId).data.Media
return SyncAPI.SyncResult(
@ -95,7 +96,7 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
(it.timeUntilAiring ?: return@let null) + unixTime
)
},
genres = season.genres,
title = season.title?.userPreferred,
synonyms = season.synonyms,
isAdult = season.isAdult,
totalEpisodes = season.episodes,
@ -333,6 +334,12 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
medium
color
}
title {
romaji
english
native
userPreferred
}
duration
episodes
genres
@ -750,6 +757,7 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
data class SeasonMedia(
@JsonProperty("id") val id: Int?,
@JsonProperty("title") val title: MediaTitle?,
@JsonProperty("idMal") val idMal: Int?,
@JsonProperty("format") val format: String?,
@JsonProperty("nextAiringEpisode") val nextAiringEpisode: SeasonNextAiringEpisode?,
@ -871,6 +879,13 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
@JsonProperty("anime") val anime: AniListFavoritesMediaConnection,
)
data class MediaTitle(
@JsonProperty("romaji") val romaji: String?,
@JsonProperty("english") val english: String?,
@JsonProperty("native") val native: String?,
@JsonProperty("userPreferred") val userPreferred: String?,
)
data class SeasonNode(
@JsonProperty("id") val id: Int,
@JsonProperty("format") val format: String?,