Update Anime4UP videoListParse function (#426)
* Update Anime4UP videoListParse function * bump the anime4UP extension version
This commit is contained in:
parent
927f9c68fd
commit
b73187e5cd
2 changed files with 42 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Anime4up'
|
extName = 'Anime4up'
|
||||||
extClass = '.Anime4Up'
|
extClass = '.Anime4Up'
|
||||||
extVersionCode = 58
|
extVersionCode = 59
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Anime4Up : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
override val name = "Anime4Up"
|
override val name = "Anime4Up"
|
||||||
|
|
||||||
override val baseUrl = "https://anime4up.cam"
|
override val baseUrl = "https://anime4up.rest"
|
||||||
|
|
||||||
override val lang = "ar"
|
override val lang = "ar"
|
||||||
|
|
||||||
|
@ -136,7 +136,6 @@ class Anime4Up : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
episode_number = name.substringAfterLast(" ").toFloatOrNull() ?: 0F
|
episode_number = name.substringAfterLast(" ").toFloatOrNull() ?: 0F
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================ Video Links =============================
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Qualities(
|
data class Qualities(
|
||||||
val fhd: Map<String, String> = emptyMap(),
|
val fhd: Map<String, String> = emptyMap(),
|
||||||
|
@ -144,14 +143,47 @@ class Anime4Up : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
val sd: Map<String, String> = emptyMap(),
|
val sd: Map<String, String> = emptyMap(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class WatchServerData(
|
||||||
|
val name: String,
|
||||||
|
val link: String,
|
||||||
|
val order: String,
|
||||||
|
val icon: Boolean
|
||||||
|
)
|
||||||
|
|
||||||
override fun videoListParse(response: Response): List<Video> {
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
val base64 = response.asJsoup().selectFirst("input[name=wl]")
|
val document = response.asJsoup()
|
||||||
|
|
||||||
|
// Decode base64 for each quality level
|
||||||
|
val base64Fhd = document.selectFirst(".WatchServersEmbed form input[name='watch_fhd']")
|
||||||
?.attr("value")
|
?.attr("value")
|
||||||
?.let { String(Base64.decode(it, Base64.DEFAULT)) }
|
?.let { String(Base64.decode(it, Base64.DEFAULT)) }
|
||||||
?: return emptyList()
|
?: "[]"
|
||||||
|
|
||||||
val parsedData = json.decodeFromString<Qualities>(base64)
|
val base64Hd = document.selectFirst(".WatchServersEmbed form input[name='watch_hd']")
|
||||||
val streamLinks = with(parsedData) { fhd + hd + sd }
|
?.attr("value")
|
||||||
|
?.let { String(Base64.decode(it, Base64.DEFAULT)) }
|
||||||
|
?: "[]"
|
||||||
|
|
||||||
|
val base64Sd = document.selectFirst(".WatchServersEmbed form input[name='watch_SD']")
|
||||||
|
?.attr("value")
|
||||||
|
?.let { String(Base64.decode(it, Base64.DEFAULT)) }
|
||||||
|
?: "[]"
|
||||||
|
|
||||||
|
// Parse the base64 decoded strings into lists of WatchServerData
|
||||||
|
val parsedFhd = json.decodeFromString<List<WatchServerData>>(base64Fhd)
|
||||||
|
val parsedHd = json.decodeFromString<List<WatchServerData>>(base64Hd)
|
||||||
|
val parsedSd = json.decodeFromString<List<WatchServerData>>(base64Sd)
|
||||||
|
|
||||||
|
// Convert to the old Qualities structure
|
||||||
|
val qualities = Qualities(
|
||||||
|
fhd = parsedFhd.associate { it.name to it.link },
|
||||||
|
hd = parsedHd.associate { it.name to it.link },
|
||||||
|
sd = parsedSd.associate { it.name to it.link }
|
||||||
|
)
|
||||||
|
|
||||||
|
// Use the same logic as the old implementation
|
||||||
|
val streamLinks = with(qualities) { fhd + hd + sd }
|
||||||
|
|
||||||
return streamLinks.values.distinct().flatMap(::extractVideos)
|
return streamLinks.values.distinct().flatMap(::extractVideos)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue