added mal to zoro

This commit is contained in:
LagradOst 2022-04-02 21:01:00 +02:00
parent cf1fc3ce3e
commit 2a663ccef1
2 changed files with 12 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.movieproviders.SflixProvider.Companion.extractRabbitStream import com.lagradost.cloudstream3.movieproviders.SflixProvider.Companion.extractRabbitStream
import com.lagradost.cloudstream3.movieproviders.SflixProvider.Companion.runSflixExtractorVerifierJob import com.lagradost.cloudstream3.movieproviders.SflixProvider.Companion.runSflixExtractorVerifierJob
import com.lagradost.cloudstream3.network.Requests.Companion.await import com.lagradost.cloudstream3.network.Requests.Companion.await
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
@ -183,10 +184,17 @@ class ZoroProvider : MainAPI() {
return Actor(name = name, image = image) return Actor(name = name, image = image)
} }
data class ZoroSyncData(
@JsonProperty("mal_id") val malId : String?,
@JsonProperty("anilist_id") val aniListId : String?,
)
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
val html = app.get(url).text val html = app.get(url).text
val document = Jsoup.parse(html) val document = Jsoup.parse(html)
val syncData = tryParseJson<ZoroSyncData>(document.selectFirst("#syncData")?.data())
val title = document.selectFirst(".anisc-detail > .film-name")?.text().toString() val title = document.selectFirst(".anisc-detail > .film-name")?.text().toString()
val poster = document.selectFirst(".anisc-poster img")?.attr("src") val poster = document.selectFirst(".anisc-poster img")?.attr("src")
val tags = document.select(".anisc-info a[href*=\"/genre/\"]").map { it.text() } val tags = document.select(".anisc-info a[href*=\"/genre/\"]").map { it.text() }
@ -283,6 +291,8 @@ class ZoroProvider : MainAPI() {
this.tags = tags this.tags = tags
this.recommendations = recommendations this.recommendations = recommendations
this.actors = actors this.actors = actors
this.malId = syncData?.malId?.toIntOrNull()
this.anilistId = syncData?.aniListId?.toIntOrNull()
} }
} }

View file

@ -229,9 +229,9 @@ object AppUtils {
return mapper.readValue(value) return mapper.readValue(value)
} }
inline fun <reified T> tryParseJson(value: String): T? { inline fun <reified T> tryParseJson(value: String?): T? {
return try { return try {
parseJson(value) parseJson(value ?: return null)
} catch (_: Exception) { } catch (_: Exception) {
null null
} }