fix(es/legionanime): Error handling (#2319)

This commit is contained in:
Diego Peña y Lillo
2023-10-05 19:39:43 -03:00
committed by GitHub
parent 8f4b5d99ce
commit a96ff5b61c
3 changed files with 8 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'LegionAnime'
pkgNameSuffix = 'es.legionanime'
extClass = '.LegionAnime'
extVersionCode = 27
extVersionCode = 28
libVersion = '13'
}

View File

@ -280,7 +280,11 @@ class LegionAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
}
}
url.contains("jkanime") -> {
listOf(JkanimeExtractor(client).getDesuFromUrl(url))
try {
listOf(JkanimeExtractor(client).getDesuFromUrl(url))
} catch (_: Exception) {
emptyList()
}
}
url.contains("/stream/amz.php?") -> {
try {

View File

@ -33,7 +33,8 @@ class JkanimeExtractor(
}
fun getDesuFromUrl(url: String): Video {
val document = client.newCall(GET(url)).execute().asJsoup()
val headers = Headers.Builder().add("Referer", "https://jkanime.net/").build()
val document = client.newCall(GET(url, headers)).execute().asJsoup()
val script = document.selectFirst("script:containsData(var parts = {)")!!.data()
val streamUrl = script.substringAfter("url: '").substringBefore("'")
return Video(streamUrl, "Desu", streamUrl)