forked from recloudstream/cloudstream
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d2beb5e253
1 changed files with 38 additions and 11 deletions
|
@ -1,13 +1,15 @@
|
|||
package com.lagradost.cloudstream3.animeproviders
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addRating
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||
import com.lagradost.cloudstream3.network.AppResponse
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.Qualities
|
||||
import org.json.JSONObject
|
||||
import org.jsoup.nodes.Element
|
||||
|
||||
class AnimeWorldProvider : MainAPI() {
|
||||
|
@ -23,6 +25,19 @@ class AnimeWorldProvider : MainAPI() {
|
|||
)
|
||||
|
||||
companion object {
|
||||
private const val cookieName = "AWCookieVerify"
|
||||
private val cookieRegex = Regex("$cookieName=(.+?)(\\s?);")
|
||||
private val cookies = mutableMapOf(cookieName to "")
|
||||
|
||||
private suspend fun request(url: String): AppResponse {
|
||||
val response = app.get(url, cookies = cookies)
|
||||
return cookieRegex.find(response.text)?.let {
|
||||
val verify = it.groups[1]?.value ?: throw ErrorLoadingException("Can't bypass protection")
|
||||
cookies[cookieName] = verify
|
||||
return app.get(url, cookies = cookies)
|
||||
} ?: response
|
||||
}
|
||||
|
||||
fun getType(t: String?): TvType {
|
||||
return when (t?.lowercase()) {
|
||||
"movie" -> TvType.AnimeMovie
|
||||
|
@ -47,9 +62,11 @@ class AnimeWorldProvider : MainAPI() {
|
|||
return h.joinToString(".")
|
||||
}
|
||||
|
||||
val title = this.select("a.name").text().removeSuffix(" (ITA)")
|
||||
val otherTitle = this.select("a.name").attr("data-jtitle").removeSuffix(" (ITA)")
|
||||
val url = fixUrl(this.select("a.name").attr("href").parseHref())
|
||||
val anchor = this.select("a.name").firstOrNull() ?: throw ErrorLoadingException("Error")
|
||||
val title = anchor.text().removeSuffix(" (ITA)")
|
||||
val otherTitle = anchor.attr("data-jtitle").removeSuffix(" (ITA)")
|
||||
|
||||
val url = fixUrl(anchor.attr("href").parseHref())
|
||||
val poster = this.select("a.poster img").attr("src")
|
||||
|
||||
val statusElement = this.select("div.status") // .first()
|
||||
|
@ -71,7 +88,7 @@ class AnimeWorldProvider : MainAPI() {
|
|||
}
|
||||
|
||||
override suspend fun getMainPage(): HomePageResponse {
|
||||
val document = app.get(mainUrl).document
|
||||
val document = request(mainUrl).document
|
||||
val list = ArrayList<HomePageList>()
|
||||
|
||||
val widget = document.select(".widget.hotnew")
|
||||
|
@ -95,7 +112,7 @@ class AnimeWorldProvider : MainAPI() {
|
|||
}
|
||||
|
||||
override suspend fun search(query: String): List<SearchResponse> {
|
||||
val document = app.get("$mainUrl/search?keyword=$query").document
|
||||
val document = request("$mainUrl/search?keyword=$query").document
|
||||
return document.select(".film-list > .item").map {
|
||||
it.toSearchResult(showEpisode = false)
|
||||
}
|
||||
|
@ -112,7 +129,7 @@ class AnimeWorldProvider : MainAPI() {
|
|||
}
|
||||
}
|
||||
|
||||
val document = app.get(url).document
|
||||
val document = request(url).document
|
||||
|
||||
val widget = document.select("div.widget.info")
|
||||
val title = widget.select(".info .title").text().removeSuffix(" (ITA)")
|
||||
|
@ -153,7 +170,7 @@ class AnimeWorldProvider : MainAPI() {
|
|||
val id = it.select("a").attr("data-id")
|
||||
val number = it.select("a").attr("data-episode-num").toIntOrNull()
|
||||
Episode(
|
||||
fixUrl("$mainUrl/api/episode/info?id=$id"),
|
||||
"$mainUrl/api/episode/info?id=$id",
|
||||
episode = number
|
||||
)
|
||||
}
|
||||
|
@ -182,15 +199,25 @@ class AnimeWorldProvider : MainAPI() {
|
|||
}
|
||||
}
|
||||
|
||||
data class Json (
|
||||
@JsonProperty("grabber") val grabber: String,
|
||||
@JsonProperty("name") val name: String,
|
||||
@JsonProperty("target") val target: String,
|
||||
)
|
||||
|
||||
override suspend fun loadLinks(
|
||||
data: String,
|
||||
isCasting: Boolean,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
): Boolean {
|
||||
val url = JSONObject(
|
||||
app.get(data).text
|
||||
).getString("grabber")
|
||||
val url = tryParseJson<Json>(
|
||||
request(data).text
|
||||
)?.grabber
|
||||
|
||||
if (url.isNullOrEmpty())
|
||||
return false
|
||||
|
||||
callback.invoke(
|
||||
ExtractorLink(
|
||||
name,
|
||||
|
|
Loading…
Reference in a new issue