mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fixed Aniworld
This commit is contained in:
parent
8e1758872c
commit
fa3a705a4b
2 changed files with 46 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -7,9 +7,11 @@ import com.lagradost.cloudstream3.extractors.DoodLaExtractor
|
||||||
import com.lagradost.cloudstream3.extractors.Voe
|
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.M3u8Helper
|
||||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
class Aniworld : MainAPI() {
|
class Aniworld : MainAPI() {
|
||||||
override var mainUrl = "https://aniworld.to"
|
override var mainUrl = "https://aniworld.to"
|
||||||
|
@ -144,26 +146,50 @@ class Aniworld : MainAPI() {
|
||||||
it.third != "Vidoza"
|
it.third != "Vidoza"
|
||||||
}.apmap {
|
}.apmap {
|
||||||
val redirectUrl = app.get(fixUrl(it.second)).url
|
val redirectUrl = app.get(fixUrl(it.second)).url
|
||||||
loadExtractor(redirectUrl, data, subtitleCallback) { link ->
|
if (it.third == "VOE") {
|
||||||
val name = "${link.name} [${it.first.getLanguage(document)}]"
|
invokeVoe(redirectUrl, data, callback)
|
||||||
callback.invoke(
|
} else {
|
||||||
ExtractorLink(
|
loadExtractor(redirectUrl, data, subtitleCallback) { link ->
|
||||||
name,
|
val name = "${link.name} [${it.first.getLanguage(document)}]"
|
||||||
name,
|
callback.invoke(
|
||||||
link.url,
|
ExtractorLink(
|
||||||
link.referer,
|
name,
|
||||||
link.quality,
|
name,
|
||||||
link.isM3u8,
|
link.url,
|
||||||
link.headers,
|
link.referer,
|
||||||
link.extractorData
|
link.quality,
|
||||||
|
link.isM3u8,
|
||||||
|
link.headers,
|
||||||
|
link.extractorData
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun invokeVoe(
|
||||||
|
url: String,
|
||||||
|
referer: String,
|
||||||
|
callback: (ExtractorLink) -> Unit,
|
||||||
|
) {
|
||||||
|
val request = app.get(url, referer = referer)
|
||||||
|
val baseUrl = getBaseUrl(request.url)
|
||||||
|
val res = request.document
|
||||||
|
val script = res.select("script").find { it.data().contains("sources =") }?.data()
|
||||||
|
val link =
|
||||||
|
Regex("[\"']hls[\"']:\\s*[\"'](.*)[\"']").find(script ?: return)?.groupValues?.get(1)
|
||||||
|
|
||||||
|
M3u8Helper.generateM3u8(
|
||||||
|
name,
|
||||||
|
link ?: return,
|
||||||
|
"$baseUrl/",
|
||||||
|
headers = mapOf("Origin" to "$baseUrl/")
|
||||||
|
).forEach(callback)
|
||||||
|
}
|
||||||
|
|
||||||
private fun Element.toSearchResult(): AnimeSearchResponse? {
|
private fun Element.toSearchResult(): AnimeSearchResponse? {
|
||||||
val href = fixUrlNull(this.selectFirst("a")?.attr("href")) ?: return null
|
val href = fixUrlNull(this.selectFirst("a")?.attr("href")) ?: return null
|
||||||
val title = this.selectFirst("h3")?.text() ?: return null
|
val title = this.selectFirst("h3")?.text() ?: return null
|
||||||
|
@ -178,6 +204,12 @@ class Aniworld : MainAPI() {
|
||||||
?.removePrefix("mit")?.trim()
|
?.removePrefix("mit")?.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getBaseUrl(url: String): String {
|
||||||
|
return URI(url).let {
|
||||||
|
"${it.scheme}://${it.host}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private data class AnimeSearch(
|
private data class AnimeSearch(
|
||||||
@JsonProperty("link") val link: String,
|
@JsonProperty("link") val link: String,
|
||||||
@JsonProperty("title") val title: String? = null,
|
@JsonProperty("title") val title: String? = null,
|
||||||
|
|
Loading…
Reference in a new issue