AnimesUp: Fix NPE on video list (#1098)

This commit is contained in:
Claudemirovsky
2022-12-21 05:53:49 -03:00
committed by GitHub
parent 617fe43d8f
commit b375293d79
4 changed files with 17 additions and 8 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'AnimesUP'
pkgNameSuffix = 'pt.animesup'
extClass = '.AnimesUp'
extVersionCode = 2
extVersionCode = 3
libVersion = '13'
}

View File

@ -124,8 +124,8 @@ class AnimesUp : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
.videoFromUrl("https:" + videoUrl, quality)
}
else -> null
} ?: Video(videoUrl, quality, videoUrl)
}
}
}.filterNotNull()
return resolutions
}

View File

@ -7,13 +7,19 @@ import okhttp3.OkHttpClient
class AnimesUpExtractor(private val client: OkHttpClient) {
fun videoFromUrl(url: String, quality: String, headers: Headers): Video {
fun videoFromUrl(url: String, quality: String, headers: Headers): Video? {
val body = client.newCall(GET(url, headers))
.execute()
.body?.string()
.orEmpty()
val videoUrl = body.substringAfter("file: \"").substringBefore("\",")
val newHeaders = Headers.headersOf("referer", url)
return Video(url, quality, videoUrl, newHeaders)
// Temporary(or not) fix: videos from this host are not working
// even on the website, returning HTTP 403 Forbidden.
return if (videoUrl.startsWith("https://video.wixstatic.com")) {
null
} else {
Video(url, quality, videoUrl, newHeaders)
}
}
}

View File

@ -47,9 +47,12 @@ class LegacyFunExtractor(private val client: OkHttpClient) {
"user-agent", USER_AGENT
)
val newDoc = client.newCall(GET(iframeUrl, newHeaders)).execute().asJsoup()
val body = newDoc.selectFirst("script:containsData(eval)").data()
val unpacked = JsUnpacker.unpackAndCombine(body)
return unpacked?.let {
val body = newDoc.let { doc ->
doc.selectFirst("script:containsData(eval)")?.let {
JsUnpacker.unpackAndCombine(it.data())
} ?: doc.selectFirst("script:containsData(var player)")?.data()
}
return body?.let {
val url = it.substringAfter("file\":")
.substringAfter("\"")
.substringBefore("\"")