Update video extraction (#1611)

This commit is contained in:
Secozzi 2023-05-16 09:57:28 +02:00 committed by GitHub
parent cc6e071a03
commit 5f31d362be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 9 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'AnimesZone'
pkgNameSuffix = 'pt.animeszone'
extClass = '.AnimesZone'
extVersionCode = 1
extVersionCode = 2
libVersion = '13'
containsNsfw = true
}

View File

@ -59,10 +59,6 @@ class AnimesZone : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
companion object {
private val episodeRegex = Regex("""Episódio ?\d+\.?\d* ?""")
private val DateFormatter by lazy {
SimpleDateFormat("d MMMM yyyy", Locale.ENGLISH)
}
}
// ============================== Popular ===============================
@ -361,6 +357,8 @@ class AnimesZone : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
when {
"/bloggerjwplayer" in url ->
videoList.addAll(BloggerJWPlayerExtractor.videosFromScript(decrypted))
"jwplayer-2" in url ->
videoList.addAll(BloggerJWPlayerExtractor.videosFromScript(decrypted))
"/m3u8" in url ->
videoList.addAll(PlaylistExtractor.videosFromScript(decrypted))
}

View File

@ -6,13 +6,22 @@ object BloggerJWPlayerExtractor {
fun videosFromScript(script: String): List<Video> {
val sources = script.substringAfter("sources: [").substringBefore("],")
return sources.split("{").drop(1).map {
val label = it.substringAfter("label").substringAfter(":\"").substringBefore('"')
return sources.split("{").drop(1).mapNotNull {
val label = it.substringAfter("label")
.substringAfter(":")
.substringAfter("\"")
.substringBefore('"')
val videoUrl = it.substringAfter("file")
.substringAfter(":\"")
.substringAfter(":")
.substringAfter("\"")
.substringBefore('"')
.replace("\\", "")
Video(videoUrl, "BloggerJWPlayer - $label", videoUrl)
if (videoUrl.isEmpty()) {
null
} else {
Video(videoUrl, "BloggerJWPlayer - $label", videoUrl)
}
}
}
}