Anitubeinua: Parse from script JSON

This commit is contained in:
CakesTwix 2023-02-19 15:48:44 +02:00
parent 80800dc8ba
commit 2dca366c12
Signed by: CakesTwix
GPG key ID: 7B11051D5CE19825
2 changed files with 32 additions and 40 deletions

View file

@ -3,13 +3,14 @@ package com.lagradost
import android.util.Log import android.util.Log
import com.lagradost.models.PlayerJson import com.lagradost.models.PlayerJson
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper
import okio.ByteString.Companion.decodeBase64
import okio.ByteString.Companion.decodeHex
import okio.ByteString.Companion.encodeUtf8
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.nio.charset.Charset
class AnitubeinuaProvider : MainAPI() { class AnitubeinuaProvider : MainAPI() {
@ -93,10 +94,28 @@ class AnitubeinuaProvider : MainAPI() {
// 12 - json with episodes // 12 - json with episodes
// Players, Episodes, Number of episodes // Players, Episodes, Number of episodes
// TODO: Parse Episodes // TODO: Parse Episodes
val playerScriptJson = document.select("script")[12].html().substringAfterLast(".init(").substringBefore(");") document.select("script").map{ script ->
val playerNames = playerScriptJson.substringAfterLast("],") if (script.data().contains("RalodePlayer.init(")) {
val numberOfEpisodes = playerScriptJson.substringAfterLast(",") val playerScriptRawJson = script.data().substringAfterLast(".init(").substringBefore(");")
Log.d("load-debug", playerScriptJson.substringAfterLast(",")) val playerEpisodesRawJson = playerScriptRawJson.substringAfter("],").substringBeforeLast(",")
val playerNamesArray = (playerScriptRawJson.substringBefore("],") + "]").dropLast(1).drop(1).split(",")
val numberOfEpisodesInt = playerScriptRawJson.substringAfterLast(",").toIntOrNull()
Log.d("load-debug", playerNamesArray[0].dropLast(1).drop(1))
// TODO: Decode string
Log.d("load-debug", decode(playerNamesArray[0]))
val playerJson = tryParseJson<List<List<PlayerJson>>>(playerEpisodesRawJson)!!
for(item in playerJson) {
for (item2 in item) {
//Log.d("load-debug", item2.name)
}
}
}
} //.substringAfterLast(".init(").substringBefore(");")
var episodes: List<Episode> = emptyList() var episodes: List<Episode> = emptyList()
@ -138,23 +157,9 @@ class AnitubeinuaProvider : MainAPI() {
.substringAfterLast("file:\'") .substringAfterLast("file:\'")
.substringBefore("\',") .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)
}
}
}
}
}
return true return true
} }
fun decode(input: String): String = java.net.URLDecoder.decode(input, "utf-16")
} }

View file

@ -2,21 +2,8 @@ package com.lagradost.models
data class PlayerJson ( data class PlayerJson (
val title : String, val name : String, // Серія 0
val folder : List<Season> val code : String, // iframe block
) val zid : Int,
val sid : Int
data class Season (
val title : String,
val folder : List<Episode>
)
data class Episode (
val title : String,
val file : String,
val id : String,
val poster : String,
val subtitle : String,
) )