animeon: fix again players

This commit is contained in:
CakesTwix 2024-05-27 14:19:40 +03:00
parent 1d7c5a097c
commit 4e9d4d606a
Signed by: CakesTwix
GPG key ID: 7B11051D5CE19825
5 changed files with 90 additions and 49 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 1 version = 2
dependencies{ dependencies{
implementation("com.google.code.gson:gson:2.9.0") implementation("com.google.code.gson:gson:2.9.0")

View file

@ -28,6 +28,9 @@ import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper
import com.lagradost.models.AnimeInfoModel import com.lagradost.models.AnimeInfoModel
import com.lagradost.models.AnimeModel 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.NewAnimeModel
import com.lagradost.models.SearchModel import com.lagradost.models.SearchModel
import com.lagradost.models.PlayerJson import com.lagradost.models.PlayerJson
@ -60,6 +63,8 @@ class AnimeONProvider : MainAPI() {
) )
private val listAnimeModel = object : TypeToken<List<AnimeModel>>() {}.type private val listAnimeModel = object : TypeToken<List<AnimeModel>>() {}.type
private val listFundub = object : TypeToken<List<FundubModel>>() {}.type
private val listFundubEpisodes = object : TypeToken<List<FundubEpisode>>() {}.type
// Done // Done
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
@ -136,25 +141,19 @@ class AnimeONProvider : MainAPI() {
val episodes = mutableListOf<Episode>() val episodes = mutableListOf<Episode>()
val playerRawJson = app.get(animeJSON.player[0].url).document.select("script").html() // Get all fundub for title and parse only first fundub/player
.substringAfterLast("file:\'") val fundubs = Gson().fromJson<List<FundubModel>>(app.get("${apiUrl}player/fundubs/${animeJSON.id}").text, listFundub)
.substringBefore("\',")
tryParseJson<List<PlayerJson>>(playerRawJson)?.map { dubs -> // Dubs Gson().fromJson<List<FundubEpisode>>(app.get("${apiUrl}player/episodes/${fundubs?.get(0)?.player?.get(0)?.id}/${fundubs?.get(0)?.fundub?.id}").text, listFundubEpisodes)?.map { epd -> // Episode
for (season in dubs.folder) { // Seasons
for (episode in season.folder) { // Episodes
episodes.add( episodes.add(
Episode( Episode(
"${season.title}, ${episode.title}, ${animeJSON.player[0].url}", "${animeJSON.id}, ${epd.episode}",
episode.title, "Епізод ${epd.episode}",
season.title.replace(" Сезон ", "").toIntOrNull(), episode = epd.episode,
episode.title.replace("Серія ", "").toIntOrNull(), posterUrl = epd.poster
episode.poster
) )
) )
} }
}
}
return if (tvType == TvType.Anime || tvType == TvType.OVA) { return if (tvType == TvType.Anime || tvType == TvType.OVA) {
newAnimeLoadResponse( newAnimeLoadResponse(
@ -193,47 +192,25 @@ class AnimeONProvider : MainAPI() {
// It works when I click to view the series // It works when I click to view the series
override suspend fun loadLinks( override suspend fun loadLinks(
data: String, // (Serisl) [Season, Episode, Player Url] | (Film) [Title, Player Url] data: String, // (Serisl) [id title, episode] | (Film) ?
isCasting: Boolean, isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val dataList = data.split(", ") val dataList = data.split(", ")
// Its film, parse one m3u8 val fundubs = Gson().fromJson<List<FundubModel>>(app.get("${apiUrl}player/fundubs/${dataList[0]}").text, listFundub)
if(dataList.size == 2){
val m3u8Url = app.get(dataList[1]).document.select("script").html() fundubs.map { dub ->
.substringAfterLast("file:\"") Gson().fromJson<List<FundubEpisode>>(app.get("${apiUrl}player/episodes/${dub.player.get(0)?.id}/${dub.fundub.id}").text, listFundubEpisodes).filter{ it.episode == dataList[1].toIntOrNull() }.map { epd -> // Episode
.substringBefore("\",")
M3u8Helper.generateM3u8( M3u8Helper.generateM3u8(
source = dataList[0], source = "${dub.fundub.name} (${dub.player[0].name})",
streamUrl = m3u8Url, streamUrl = getM3U(app.get("${apiUrl}player/episode/${epd.id}").parsedSafe<FundubVideoUrl>()!!.videoUrl),
referer = "https://tortuga.wtf/" referer = "https://animeon.club"
).forEach(callback)
return true
}
val playerRawJson = app.get(dataList[2]).document.select("script").html()
.substringAfterLast("file:\'")
.substringBefore("\',")
tryParseJson<List<PlayerJson>>(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) ).forEach(callback)
} }
} }
}
}
}
return true return true
} }
@ -245,4 +222,23 @@ class AnimeONProvider : MainAPI() {
return value.value.toIntOrNull() 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 ""
}
}
}
} }

View file

@ -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
)

View file

@ -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<FundubPlayer>
)
data class Fundub (
@SerializedName("id") val id : Int,
@SerializedName("name") val name : String,
@SerializedName("synonyms") val synonyms : List<String>,
@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
)

View file

@ -0,0 +1,7 @@
package com.lagradost.models
import com.google.gson.annotations.SerializedName
class FundubVideoUrl (
@SerializedName("videoUrl") val videoUrl : String
)