Aniworld: fix langKey

This commit is contained in:
hexated 2023-06-15 23:56:00 +07:00
parent 4e962508b7
commit 1ebde0308d

View file

@ -7,6 +7,7 @@ import com.lagradost.cloudstream3.extractors.Voe
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
class Aniworld : MainAPI() { class Aniworld : MainAPI() {
@ -135,7 +136,7 @@ class Aniworld : MainAPI() {
}.apmap { }.apmap {
val redirectUrl = app.get(fixUrl(it.second)).url val redirectUrl = app.get(fixUrl(it.second)).url
loadExtractor(redirectUrl, data, subtitleCallback) { link -> loadExtractor(redirectUrl, data, subtitleCallback) { link ->
val name = "${link.name} [${it.first.getLanguage()}]" val name = "${link.name} [${it.first.getLanguage(document)}]"
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
name, name,
@ -163,15 +164,9 @@ class Aniworld : MainAPI() {
} }
} }
private fun String.getLanguage() : String { private fun String.getLanguage(document: Document): String? {
return when(this) { return document.selectFirst("div.changeLanguageBox img[data-lang-key=$this]")?.attr("title")
"1" -> "Deutsch" ?.removePrefix("mit")?.trim()
"2" -> "Untertitel Deutsch"
"3" -> "Untertitel Englisch"
else -> {
""
}
}
} }
private data class AnimeSearch( private data class AnimeSearch(