diff --git a/AnimeONProvider/build.gradle.kts b/AnimeONProvider/build.gradle.kts index 1b6607c..57584a8 100644 --- a/AnimeONProvider/build.gradle.kts +++ b/AnimeONProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 1 +version = 2 dependencies{ implementation("com.google.code.gson:gson:2.9.0") diff --git a/AnimeONProvider/src/main/kotlin/com/lagradost/AnimeONProvider.kt b/AnimeONProvider/src/main/kotlin/com/lagradost/AnimeONProvider.kt index 4e6e2b9..4c360ac 100644 --- a/AnimeONProvider/src/main/kotlin/com/lagradost/AnimeONProvider.kt +++ b/AnimeONProvider/src/main/kotlin/com/lagradost/AnimeONProvider.kt @@ -28,6 +28,9 @@ import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.models.AnimeInfoModel import com.lagradost.models.AnimeModel +import com.lagradost.models.FundubEpisode +import com.lagradost.models.FundubModel +import com.lagradost.models.FundubVideoUrl import com.lagradost.models.NewAnimeModel import com.lagradost.models.SearchModel import com.lagradost.models.PlayerJson @@ -60,6 +63,8 @@ class AnimeONProvider : MainAPI() { ) private val listAnimeModel = object : TypeToken>() {}.type + private val listFundub = object : TypeToken>() {}.type + private val listFundubEpisodes = object : TypeToken>() {}.type // Done override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { @@ -136,24 +141,18 @@ class AnimeONProvider : MainAPI() { val episodes = mutableListOf() - val playerRawJson = app.get(animeJSON.player[0].url).document.select("script").html() - .substringAfterLast("file:\'") - .substringBefore("\',") + // Get all fundub for title and parse only first fundub/player + val fundubs = Gson().fromJson>(app.get("${apiUrl}player/fundubs/${animeJSON.id}").text, listFundub) - tryParseJson>(playerRawJson)?.map { dubs -> // Dubs - for (season in dubs.folder) { // Seasons - for (episode in season.folder) { // Episodes - episodes.add( - Episode( - "${season.title}, ${episode.title}, ${animeJSON.player[0].url}", - episode.title, - season.title.replace(" Сезон ", "").toIntOrNull(), - episode.title.replace("Серія ", "").toIntOrNull(), - episode.poster - ) + Gson().fromJson>(app.get("${apiUrl}player/episodes/${fundubs?.get(0)?.player?.get(0)?.id}/${fundubs?.get(0)?.fundub?.id}").text, listFundubEpisodes)?.map { epd -> // Episode + episodes.add( + Episode( + "${animeJSON.id}, ${epd.episode}", + "Епізод ${epd.episode}", + episode = epd.episode, + posterUrl = epd.poster ) - } - } + ) } return if (tvType == TvType.Anime || tvType == TvType.OVA) { @@ -193,47 +192,25 @@ class AnimeONProvider : MainAPI() { // It works when I click to view the series override suspend fun loadLinks( - data: String, // (Serisl) [Season, Episode, Player Url] | (Film) [Title, Player Url] + data: String, // (Serisl) [id title, episode] | (Film) ? isCasting: Boolean, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ): Boolean { val dataList = data.split(", ") - // Its film, parse one m3u8 - if(dataList.size == 2){ - val m3u8Url = app.get(dataList[1]).document.select("script").html() - .substringAfterLast("file:\"") - .substringBefore("\",") - M3u8Helper.generateM3u8( - source = dataList[0], - streamUrl = m3u8Url, - referer = "https://tortuga.wtf/" - ).forEach(callback) + val fundubs = Gson().fromJson>(app.get("${apiUrl}player/fundubs/${dataList[0]}").text, listFundub) - return true - } - - val playerRawJson = app.get(dataList[2]).document.select("script").html() - .substringAfterLast("file:\'") - .substringBefore("\',") - - tryParseJson>(playerRawJson)?.map { dubs -> // Dubs - for(season in dubs.folder){ // Seasons - if(season.title == dataList[0]){ - for(episode in season.folder){ // Episodes - if(episode.title == dataList[1]){ - // Add as source - M3u8Helper.generateM3u8( - source = dubs.title, - streamUrl = episode.file, - referer = "https://tortuga.wtf/" - ).forEach(callback) - } - } - } + fundubs.map { dub -> + Gson().fromJson>(app.get("${apiUrl}player/episodes/${dub.player.get(0)?.id}/${dub.fundub.id}").text, listFundubEpisodes).filter{ it.episode == dataList[1].toIntOrNull() }.map { epd -> // Episode + M3u8Helper.generateM3u8( + source = "${dub.fundub.name} (${dub.player[0].name})", + streamUrl = getM3U(app.get("${apiUrl}player/episode/${epd.id}").parsedSafe()!!.videoUrl), + referer = "https://animeon.club" + ).forEach(callback) } } + return true } @@ -245,4 +222,23 @@ class AnimeONProvider : MainAPI() { return value.value.toIntOrNull() } + + private suspend fun getM3U(url: String): String{ + with(url){ + when { + contains("https://moonanime.art") -> { + val document = app.get(this).document + return document.select("script[type*=text/javascript]").html().substringAfter("file:\"").substringBefore("\",") + } + + contains("https://ashdi.vip/vod") -> { + return app.get(this).document.select("script").html() + .substringAfterLast("file:\"") + .substringBefore("\",") + } + + else -> return "" + } + } + } } diff --git a/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubEpisodes.kt b/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubEpisodes.kt new file mode 100644 index 0000000..02cbb2a --- /dev/null +++ b/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubEpisodes.kt @@ -0,0 +1,11 @@ +package com.lagradost.models + +import com.google.gson.annotations.SerializedName + +data class FundubEpisode ( + + @SerializedName("id") val id : Int, + @SerializedName("episode") val episode : Int, + @SerializedName("subtitles") val subtitles : Boolean, + @SerializedName("poster") val poster : String +) \ No newline at end of file diff --git a/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubModel.kt b/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubModel.kt new file mode 100644 index 0000000..ae60a34 --- /dev/null +++ b/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubModel.kt @@ -0,0 +1,27 @@ +package com.lagradost.models + +import com.google.gson.annotations.SerializedName + +class FundubModel ( + + @SerializedName("fundub") val fundub : Fundub, + @SerializedName("player") val player : List +) + +data class Fundub ( + + @SerializedName("id") val id : Int, + @SerializedName("name") val name : String, + @SerializedName("synonyms") val synonyms : List, + @SerializedName("description") val description : String, + @SerializedName("team") val team : String, + @SerializedName("telegram") val telegram : String, + @SerializedName("youtube") val youtube : String, + @SerializedName("avatar") val avatar : String +) + +data class FundubPlayer ( + + @SerializedName("name") val name : String, + @SerializedName("id") val id : Int +) \ No newline at end of file diff --git a/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubVideoUrl.kt b/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubVideoUrl.kt new file mode 100644 index 0000000..7eb5cfe --- /dev/null +++ b/AnimeONProvider/src/main/kotlin/com/lagradost/models/FundubVideoUrl.kt @@ -0,0 +1,7 @@ +package com.lagradost.models + +import com.google.gson.annotations.SerializedName + +class FundubVideoUrl ( + @SerializedName("videoUrl") val videoUrl : String +) \ No newline at end of file