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' extName = 'AnimesUP'
pkgNameSuffix = 'pt.animesup' pkgNameSuffix = 'pt.animesup'
extClass = '.AnimesUp' extClass = '.AnimesUp'
extVersionCode = 2 extVersionCode = 3
libVersion = '13' libVersion = '13'
} }

View File

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

View File

@ -7,13 +7,19 @@ import okhttp3.OkHttpClient
class AnimesUpExtractor(private val client: 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)) val body = client.newCall(GET(url, headers))
.execute() .execute()
.body?.string() .body?.string()
.orEmpty() .orEmpty()
val videoUrl = body.substringAfter("file: \"").substringBefore("\",") val videoUrl = body.substringAfter("file: \"").substringBefore("\",")
val newHeaders = Headers.headersOf("referer", url) 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 "user-agent", USER_AGENT
) )
val newDoc = client.newCall(GET(iframeUrl, newHeaders)).execute().asJsoup() val newDoc = client.newCall(GET(iframeUrl, newHeaders)).execute().asJsoup()
val body = newDoc.selectFirst("script:containsData(eval)").data() val body = newDoc.let { doc ->
val unpacked = JsUnpacker.unpackAndCombine(body) doc.selectFirst("script:containsData(eval)")?.let {
return unpacked?.let { JsUnpacker.unpackAndCombine(it.data())
} ?: doc.selectFirst("script:containsData(var player)")?.data()
}
return body?.let {
val url = it.substringAfter("file\":") val url = it.substringAfter("file\":")
.substringAfter("\"") .substringAfter("\"")
.substringBefore("\"") .substringBefore("\"")