mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
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
|
package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addRating
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addRating
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
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.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.Qualities
|
import com.lagradost.cloudstream3.utils.Qualities
|
||||||
import org.json.JSONObject
|
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
|
||||||
class AnimeWorldProvider : MainAPI() {
|
class AnimeWorldProvider : MainAPI() {
|
||||||
|
@ -23,6 +25,19 @@ class AnimeWorldProvider : MainAPI() {
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
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 {
|
fun getType(t: String?): TvType {
|
||||||
return when (t?.lowercase()) {
|
return when (t?.lowercase()) {
|
||||||
"movie" -> TvType.AnimeMovie
|
"movie" -> TvType.AnimeMovie
|
||||||
|
@ -47,9 +62,11 @@ class AnimeWorldProvider : MainAPI() {
|
||||||
return h.joinToString(".")
|
return h.joinToString(".")
|
||||||
}
|
}
|
||||||
|
|
||||||
val title = this.select("a.name").text().removeSuffix(" (ITA)")
|
val anchor = this.select("a.name").firstOrNull() ?: throw ErrorLoadingException("Error")
|
||||||
val otherTitle = this.select("a.name").attr("data-jtitle").removeSuffix(" (ITA)")
|
val title = anchor.text().removeSuffix(" (ITA)")
|
||||||
val url = fixUrl(this.select("a.name").attr("href").parseHref())
|
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 poster = this.select("a.poster img").attr("src")
|
||||||
|
|
||||||
val statusElement = this.select("div.status") // .first()
|
val statusElement = this.select("div.status") // .first()
|
||||||
|
@ -71,7 +88,7 @@ class AnimeWorldProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMainPage(): HomePageResponse {
|
override suspend fun getMainPage(): HomePageResponse {
|
||||||
val document = app.get(mainUrl).document
|
val document = request(mainUrl).document
|
||||||
val list = ArrayList<HomePageList>()
|
val list = ArrayList<HomePageList>()
|
||||||
|
|
||||||
val widget = document.select(".widget.hotnew")
|
val widget = document.select(".widget.hotnew")
|
||||||
|
@ -95,7 +112,7 @@ class AnimeWorldProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
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 {
|
return document.select(".film-list > .item").map {
|
||||||
it.toSearchResult(showEpisode = false)
|
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 widget = document.select("div.widget.info")
|
||||||
val title = widget.select(".info .title").text().removeSuffix(" (ITA)")
|
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 id = it.select("a").attr("data-id")
|
||||||
val number = it.select("a").attr("data-episode-num").toIntOrNull()
|
val number = it.select("a").attr("data-episode-num").toIntOrNull()
|
||||||
Episode(
|
Episode(
|
||||||
fixUrl("$mainUrl/api/episode/info?id=$id"),
|
"$mainUrl/api/episode/info?id=$id",
|
||||||
episode = number
|
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(
|
override suspend fun loadLinks(
|
||||||
data: String,
|
data: String,
|
||||||
isCasting: Boolean,
|
isCasting: Boolean,
|
||||||
subtitleCallback: (SubtitleFile) -> Unit,
|
subtitleCallback: (SubtitleFile) -> Unit,
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val url = JSONObject(
|
val url = tryParseJson<Json>(
|
||||||
app.get(data).text
|
request(data).text
|
||||||
).getString("grabber")
|
)?.grabber
|
||||||
|
|
||||||
|
if (url.isNullOrEmpty())
|
||||||
|
return false
|
||||||
|
|
||||||
callback.invoke(
|
callback.invoke(
|
||||||
ExtractorLink(
|
ExtractorLink(
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Reference in a new issue