mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
minor refactor, mapper.readValue -> parseJson
This commit is contained in:
parent
31ee495bc1
commit
420bc5abbe
21 changed files with 90 additions and 95 deletions
|
@ -22,6 +22,7 @@ import com.lagradost.cloudstream3.utils.UIHelper
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.hasPIPPermission
|
import com.lagradost.cloudstream3.utils.UIHelper.hasPIPPermission
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
|
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object CommonActivity {
|
object CommonActivity {
|
||||||
|
@ -115,6 +116,8 @@ object CommonActivity {
|
||||||
act.hasPIPPermission() // CHECK IF FEATURE IS ENABLED IN SETTINGS
|
act.hasPIPPermission() // CHECK IF FEATURE IS ENABLED IN SETTINGS
|
||||||
|
|
||||||
act.updateLocale()
|
act.updateLocale()
|
||||||
|
|
||||||
|
NewPipe.init(DownloaderTestImpl.getInstance())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Activity.enterPIPMode() {
|
private fun Activity.enterPIPMode() {
|
||||||
|
|
|
@ -615,7 +615,6 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
|
|
||||||
loadCache()
|
loadCache()
|
||||||
test()
|
test()
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance())
|
|
||||||
updateHasTrailers()
|
updateHasTrailers()
|
||||||
/*nav_view.setOnNavigationItemSelectedListener { item ->
|
/*nav_view.setOnNavigationItemSelectedListener { item ->
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.lagradost.cloudstream3.animeproviders
|
package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
||||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||||
|
@ -165,7 +164,7 @@ class AllAnimeProvider : MainAPI() {
|
||||||
res = app.get(link).text
|
res = app.get(link).text
|
||||||
if (res.contains("PERSISTED_QUERY_NOT_FOUND")) return emptyList()
|
if (res.contains("PERSISTED_QUERY_NOT_FOUND")) return emptyList()
|
||||||
}
|
}
|
||||||
val response = mapper.readValue<AllAnimeQuery>(res)
|
val response = parseJson<AllAnimeQuery>(res)
|
||||||
|
|
||||||
val results = response.data.shows.edges.filter {
|
val results = response.data.shows.edges.filter {
|
||||||
// filtering in case there is an anime with 0 episodes available on the site.
|
// filtering in case there is an anime with 0 episodes available on the site.
|
||||||
|
@ -211,7 +210,7 @@ class AllAnimeProvider : MainAPI() {
|
||||||
|
|
||||||
rhino.evaluateString(scope, js, "JavaScript", 1, null)
|
rhino.evaluateString(scope, js, "JavaScript", 1, null)
|
||||||
val jsEval = scope.get("returnValue", scope) ?: return null
|
val jsEval = scope.get("returnValue", scope) ?: return null
|
||||||
val showData = mapper.readValue<Edges>(jsEval as String)
|
val showData = parseJson<Edges>(jsEval as String)
|
||||||
|
|
||||||
val title = showData.name
|
val title = showData.name
|
||||||
val description = showData.description
|
val description = showData.description
|
||||||
|
@ -230,7 +229,7 @@ class AllAnimeProvider : MainAPI() {
|
||||||
}) else null)
|
}) else null)
|
||||||
}
|
}
|
||||||
|
|
||||||
val characters = soup.select("div.character > div.card-character-box")?.mapNotNull {
|
val characters = soup.select("div.character > div.card-character-box").mapNotNull {
|
||||||
val img = it?.selectFirst("img")?.attr("src") ?: return@mapNotNull null
|
val img = it?.selectFirst("img")?.attr("src") ?: return@mapNotNull null
|
||||||
val name = it.selectFirst("div > a")?.ownText() ?: return@mapNotNull null
|
val name = it.selectFirst("div > a")?.ownText() ?: return@mapNotNull null
|
||||||
val role = when (it.selectFirst("div > .text-secondary")?.text()?.trim()) {
|
val role = when (it.selectFirst("div > .text-secondary")?.text()?.trim()) {
|
||||||
|
@ -333,7 +332,7 @@ class AllAnimeProvider : MainAPI() {
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var apiEndPoint =
|
var apiEndPoint =
|
||||||
mapper.readValue<ApiEndPoint>(app.get("$mainUrl/getVersion").text).episodeIframeHead
|
parseJson<ApiEndPoint>(app.get("$mainUrl/getVersion").text).episodeIframeHead
|
||||||
if (apiEndPoint.endsWith("/")) apiEndPoint =
|
if (apiEndPoint.endsWith("/")) apiEndPoint =
|
||||||
apiEndPoint.slice(0 until apiEndPoint.length - 1)
|
apiEndPoint.slice(0 until apiEndPoint.length - 1)
|
||||||
|
|
||||||
|
@ -370,7 +369,7 @@ class AllAnimeProvider : MainAPI() {
|
||||||
val response = app.get(link)
|
val response = app.get(link)
|
||||||
|
|
||||||
if (response.code < 400) {
|
if (response.code < 400) {
|
||||||
val links = mapper.readValue<AllAnimeVideoApiResponse>(response.text).links
|
val links = parseJson<AllAnimeVideoApiResponse>(response.text).links
|
||||||
links.forEach { server ->
|
links.forEach { server ->
|
||||||
if (server.hls != null && server.hls) {
|
if (server.hls != null && server.hls) {
|
||||||
getM3u8Qualities(
|
getM3u8Qualities(
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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.addTrailer
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||||
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
|
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.JsUnpacker
|
import com.lagradost.cloudstream3.utils.JsUnpacker
|
||||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
|
@ -82,7 +83,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
for (i in urls) {
|
for (i in urls) {
|
||||||
try {
|
try {
|
||||||
val response = app.get(i.first).text
|
val response = app.get(i.first).text
|
||||||
val episodes = mapper.readValue<AnimePaheLatestReleases>(response).data.map {
|
val episodes = parseJson<AnimePaheLatestReleases>(response).data.map {
|
||||||
newAnimeSearchResponse(
|
newAnimeSearchResponse(
|
||||||
it.animeTitle,
|
it.animeTitle,
|
||||||
"https://pahe.win/a/${it.animeId}?slug=${it.animeTitle}",
|
"https://pahe.win/a/${it.animeId}?slug=${it.animeTitle}",
|
||||||
|
@ -127,7 +128,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
val headers = mapOf("referer" to "$mainUrl/")
|
val headers = mapOf("referer" to "$mainUrl/")
|
||||||
|
|
||||||
val req = app.get(url, headers = headers).text
|
val req = app.get(url, headers = headers).text
|
||||||
val data = req.let { mapper.readValue<AnimePaheSearch>(it) }
|
val data = parseJson<AnimePaheSearch>(req)
|
||||||
for (anime in data.data) {
|
for (anime in data.data) {
|
||||||
if (anime.id == animeId) {
|
if (anime.id == animeId) {
|
||||||
return "https://animepahe.com/anime/${anime.session}"
|
return "https://animepahe.com/anime/${anime.session}"
|
||||||
|
@ -142,7 +143,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
val headers = mapOf("referer" to "$mainUrl/")
|
val headers = mapOf("referer" to "$mainUrl/")
|
||||||
|
|
||||||
val req = app.get(url, headers = headers).text
|
val req = app.get(url, headers = headers).text
|
||||||
val data = req.let { mapper.readValue<AnimePaheSearch>(it) }
|
val data = parseJson<AnimePaheSearch>(req)
|
||||||
|
|
||||||
return data.data.map {
|
return data.data.map {
|
||||||
newAnimeSearchResponse(
|
newAnimeSearchResponse(
|
||||||
|
@ -188,7 +189,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
val headers = mapOf("referer" to "$mainUrl/")
|
val headers = mapOf("referer" to "$mainUrl/")
|
||||||
|
|
||||||
val req = app.get(uri, headers = headers).text
|
val req = app.get(uri, headers = headers).text
|
||||||
val data = req.let { mapper.readValue<AnimePaheAnimeData>(it) }
|
val data = parseJson<AnimePaheAnimeData>(req)
|
||||||
|
|
||||||
val lastPage = data.lastPage
|
val lastPage = data.lastPage
|
||||||
val perPage = data.perPage
|
val perPage = data.perPage
|
||||||
|
@ -518,7 +519,7 @@ class AnimePaheProvider : MainAPI() {
|
||||||
link = link.replace(regex, "")
|
link = link.replace(regex, "")
|
||||||
|
|
||||||
val req = app.get(link, headers = headers).text
|
val req = app.get(link, headers = headers).text
|
||||||
val jsonResponse = req.let { mapper.readValue<AnimePaheAnimeData>(it) }
|
val jsonResponse = parseJson<AnimePaheAnimeData>(req)
|
||||||
val ep = ((jsonResponse.data.map {
|
val ep = ((jsonResponse.data.map {
|
||||||
if (it.episode == episodeNum) {
|
if (it.episode == episodeNum) {
|
||||||
it
|
it
|
||||||
|
|
|
@ -72,7 +72,7 @@ class AnimekisaProvider : MainAPI() {
|
||||||
val title = it.selectFirst("h3 a")?.text() ?: ""
|
val title = it.selectFirst("h3 a")?.text() ?: ""
|
||||||
val url = it.selectFirst("a.film-poster-ahref")?.attr("href")
|
val url = it.selectFirst("a.film-poster-ahref")?.attr("href")
|
||||||
?.replace("watch/", "anime/")?.replace(
|
?.replace("watch/", "anime/")?.replace(
|
||||||
Regex("(-episode-(\\d+)\\/\$|-episode-(\\d+)\$|-episode-full|-episode-.*-.(\\/|))"),
|
Regex("(-episode-(\\d+)/\$|-episode-(\\d+)\$|-episode-full|-episode-.*-.(/|))"),
|
||||||
""
|
""
|
||||||
) ?: return@mapNotNull null
|
) ?: return@mapNotNull null
|
||||||
val poster = it.selectFirst(".film-poster img")?.attr("data-src")
|
val poster = it.selectFirst(".film-poster img")?.attr("data-src")
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.lagradost.cloudstream3.animeproviders
|
package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.APIHolder.unixTime
|
import com.lagradost.cloudstream3.APIHolder.unixTime
|
||||||
import com.lagradost.cloudstream3.APIHolder.unixTimeMS
|
import com.lagradost.cloudstream3.APIHolder.unixTimeMS
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
|
@ -117,7 +117,7 @@ class DubbedAnimeProvider : MainAPI() {
|
||||||
val url =
|
val url =
|
||||||
mainUrl + (if (isMovie) "/movies/jsonMovie" else "/xz/v3/jsonEpi") + ".php?slug=$slug&_=$unixTime"
|
mainUrl + (if (isMovie) "/movies/jsonMovie" else "/xz/v3/jsonEpi") + ".php?slug=$slug&_=$unixTime"
|
||||||
val response = app.get(url).text
|
val response = app.get(url).text
|
||||||
val mapped = mapper.readValue<QueryEpisodeResultRoot>(response)
|
val mapped = parseJson<QueryEpisodeResultRoot>(response)
|
||||||
return mapped.result.anime.first()
|
return mapped.result.anime.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package com.lagradost.cloudstream3.animeproviders
|
package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.utils.*
|
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.M3u8Helper.Companion.generateM3u8
|
import com.lagradost.cloudstream3.utils.M3u8Helper.Companion.generateM3u8
|
||||||
|
import com.lagradost.cloudstream3.utils.getAndUnpack
|
||||||
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
|
|
||||||
|
|
||||||
class MundoDonghuaProvider : MainAPI() {
|
class MundoDonghuaProvider : MainAPI() {
|
||||||
|
|
|
@ -206,7 +206,7 @@ class NineAnimeProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse>? {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
val vrf = encodeVrf(query)
|
val vrf = encodeVrf(query)
|
||||||
//?language%5B%5D=${if (selectDub) "dubbed" else "subbed"}&
|
//?language%5B%5D=${if (selectDub) "dubbed" else "subbed"}&
|
||||||
val url =
|
val url =
|
||||||
|
|
|
@ -2,10 +2,10 @@ package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.network.DdosGuardKiller
|
import com.lagradost.cloudstream3.network.DdosGuardKiller
|
||||||
import com.lagradost.cloudstream3.network.getHeaders
|
import com.lagradost.cloudstream3.network.getHeaders
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
|
@ -253,7 +253,7 @@ class TenshiProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
val similarAnime = document.select("ul.anime-loop > li > a")?.mapNotNull { element ->
|
val similarAnime = document.select("ul.anime-loop > li > a").mapNotNull { element ->
|
||||||
val href = element.attr("href") ?: return@mapNotNull null
|
val href = element.attr("href") ?: return@mapNotNull null
|
||||||
val title =
|
val title =
|
||||||
element.selectFirst("> .overlay > .thumb-title")?.text() ?: return@mapNotNull null
|
element.selectFirst("> .overlay > .thumb-title")?.text() ?: return@mapNotNull null
|
||||||
|
@ -321,7 +321,7 @@ class TenshiProvider : MainAPI() {
|
||||||
sourceHTML
|
sourceHTML
|
||||||
)
|
)
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
val qualities = mapper.readValue<List<Quality>>(
|
val qualities = parseJson<List<Quality>>(
|
||||||
match.destructured.component1()
|
match.destructured.component1()
|
||||||
.replace("'", "\"")
|
.replace("'", "\"")
|
||||||
.replace(Regex("""(\w+): """), "\"\$1\": ")
|
.replace(Regex("""(\w+): """), "\"\$1\": ")
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.lagradost.cloudstream3.animeproviders
|
package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
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.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
|
@ -238,7 +238,7 @@ class WatchCartoonOnlineProvider : MainAPI() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val link = mapper.readValue<LinkResponse>(linkResponse.text)
|
val link = parseJson<LinkResponse>(linkResponse.text)
|
||||||
|
|
||||||
val hdLink = "${link.server}/getvid?evid=${link.hd}"
|
val hdLink = "${link.server}/getvid?evid=${link.hd}"
|
||||||
val sdLink = "${link.server}/getvid?evid=${link.enc}"
|
val sdLink = "${link.server}/getvid?evid=${link.enc}"
|
||||||
|
|
|
@ -2,12 +2,12 @@ package com.lagradost.cloudstream3.animeproviders
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
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.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.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
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
|
||||||
|
@ -210,7 +210,7 @@ class ZoroProvider : MainAPI() {
|
||||||
val animeId = URI(url).path.split("-").last()
|
val animeId = URI(url).path.split("-").last()
|
||||||
|
|
||||||
val episodes = Jsoup.parse(
|
val episodes = Jsoup.parse(
|
||||||
mapper.readValue<Response>(
|
parseJson<Response>(
|
||||||
app.get(
|
app.get(
|
||||||
"$mainUrl/ajax/v2/episode/list/$animeId"
|
"$mainUrl/ajax/v2/episode/list/$animeId"
|
||||||
).text
|
).text
|
||||||
|
@ -223,7 +223,7 @@ class ZoroProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val actors = document.select("div.block-actors-content > div.bac-list-wrap > div.bac-item")
|
val actors = document.select("div.block-actors-content > div.bac-list-wrap > div.bac-item")
|
||||||
?.mapNotNull { head ->
|
.mapNotNull { head ->
|
||||||
val subItems = head.select(".per-info") ?: return@mapNotNull null
|
val subItems = head.select(".per-info") ?: return@mapNotNull null
|
||||||
if (subItems.isEmpty()) return@mapNotNull null
|
if (subItems.isEmpty()) return@mapNotNull null
|
||||||
var role: ActorRole? = null
|
var role: ActorRole? = null
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package com.lagradost.cloudstream3.extractors
|
package com.lagradost.cloudstream3.extractors
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.app
|
import com.lagradost.cloudstream3.app
|
||||||
import com.lagradost.cloudstream3.mapper
|
import com.lagradost.cloudstream3.utils.AppUtils
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorApi
|
import com.lagradost.cloudstream3.utils.ExtractorApi
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
|
@ -73,7 +72,7 @@ open class XStreamCdn : ExtractorApi() {
|
||||||
val text = this.text
|
val text = this.text
|
||||||
if (text.isEmpty()) return listOf()
|
if (text.isEmpty()) return listOf()
|
||||||
if (text == """{"success":false,"data":"Video not found or has been removed"}""") return listOf()
|
if (text == """{"success":false,"data":"Video not found or has been removed"}""") return listOf()
|
||||||
mapper.readValue<ResponseJson?>(text)?.let {
|
AppUtils.parseJson<ResponseJson?>(text)?.let {
|
||||||
if (it.success && it.data != null) {
|
if (it.success && it.data != null) {
|
||||||
it.data.forEach { data ->
|
it.data.forEach { data ->
|
||||||
extractedLinksList.add(
|
extractedLinksList.add(
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.lagradost.cloudstream3.utils.Qualities
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
|
||||||
class EjaTv : MainAPI() {
|
class EjaTv : MainAPI() {
|
||||||
override var mainUrl = "https://eja.tv/"
|
override var mainUrl = "https://eja.tv"
|
||||||
override var name = "Eja.tv"
|
override var name = "Eja.tv"
|
||||||
|
|
||||||
// Universal language?
|
// Universal language?
|
||||||
|
@ -25,6 +25,7 @@ class EjaTv : MainAPI() {
|
||||||
val href = fixUrl(link.attr("href"))
|
val href = fixUrl(link.attr("href"))
|
||||||
val img = this.selectFirst("div.thumb img")
|
val img = this.selectFirst("div.thumb img")
|
||||||
val lang = this.selectFirst(".card-title > a")?.attr("href")?.removePrefix("?country=")
|
val lang = this.selectFirst(".card-title > a")?.attr("href")?.removePrefix("?country=")
|
||||||
|
?.replace("int", "eu") //international -> European Union 🇪🇺
|
||||||
return LiveSearchResponse(
|
return LiveSearchResponse(
|
||||||
// Kinda hack way to get the title
|
// Kinda hack way to get the title
|
||||||
img?.attr("alt")?.replaceFirst("Watch ", "") ?: return null,
|
img?.attr("alt")?.replaceFirst("Watch ", "") ?: return null,
|
||||||
|
@ -45,7 +46,6 @@ class EjaTv : MainAPI() {
|
||||||
"Entertainment" to mapOf("language" to language, "category" to "Entertainment")
|
"Entertainment" to mapOf("language" to language, "category" to "Entertainment")
|
||||||
)
|
)
|
||||||
return HomePageResponse(dataMap.apmap { (title, data) ->
|
return HomePageResponse(dataMap.apmap { (title, data) ->
|
||||||
println("ADDED isHorizontalImages")
|
|
||||||
val document = app.post(mainUrl, data = data).document
|
val document = app.post(mainUrl, data = data).document
|
||||||
val shows = document.select("div.card-body").mapNotNull {
|
val shows = document.select("div.card-body").mapNotNull {
|
||||||
it.toSearchResponse()
|
it.toSearchResponse()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.lagradost.cloudstream3.movieproviders
|
package com.lagradost.cloudstream3.movieproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
|
@ -20,17 +20,19 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
val document = app.get(mainUrl, referer = mainUrl).document
|
val document = app.get(mainUrl, referer = mainUrl).document
|
||||||
val mainbody = document.getElementsByTag("body")
|
val mainbody = document.getElementsByTag("body")
|
||||||
|
|
||||||
mainbody?.select("div.section-cotent.col-md-12.bordert")?.forEach { row ->
|
mainbody.select("div.section-cotent.col-md-12.bordert").forEach { row ->
|
||||||
val title = row?.select("div.title-section.tt")?.text() ?: "<Row>"
|
val title = row?.select("div.title-section.tt")?.text() ?: "<Row>"
|
||||||
val elements = row?.select("li.img_frame.preview-tumb7")?.mapNotNull {
|
val elements = row?.select("li.img_frame.preview-tumb7")?.mapNotNull {
|
||||||
// Get inner div from article
|
// Get inner div from article
|
||||||
val innerBody = it?.selectFirst("a") ?: return@mapNotNull null
|
val innerBody = it?.selectFirst("a") ?: return@mapNotNull null
|
||||||
// Fetch details
|
// Fetch details
|
||||||
val name = it.text()?.trim()
|
val name = it.text().trim()
|
||||||
if (name.isNullOrBlank()) { return@mapNotNull null }
|
if (name.isBlank()) {
|
||||||
|
return@mapNotNull null
|
||||||
|
}
|
||||||
|
|
||||||
val link = innerBody.attr("href") ?: return@mapNotNull null
|
val link = innerBody.attr("href") ?: return@mapNotNull null
|
||||||
val image = fixUrlNull(innerBody.select("img")?.attr("src"))
|
val image = fixUrlNull(innerBody.select("img").attr("src"))
|
||||||
//Log.i(this.name, "Result => (innerBody, image) ${innerBody} / ${image}")
|
//Log.i(this.name, "Result => (innerBody, image) ${innerBody} / ${image}")
|
||||||
// Get Year from Link
|
// Get Year from Link
|
||||||
val rex = Regex("_(\\d+)_")
|
val rex = Regex("_(\\d+)_")
|
||||||
|
@ -60,7 +62,7 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
val url = "$mainUrl/search/?q=${query.replace(" ", "+")}"
|
val url = "$mainUrl/search/?q=${query.replace(" ", "+")}"
|
||||||
val document = app.get(url).document.select("div.portfolio-thumb")
|
val document = app.get(url).document.select("div.portfolio-thumb")
|
||||||
return document?.mapNotNull {
|
return document.mapNotNull {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
return@mapNotNull null
|
return@mapNotNull null
|
||||||
}
|
}
|
||||||
|
@ -77,13 +79,13 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
posterUrl = image,
|
posterUrl = image,
|
||||||
year = year
|
year = year
|
||||||
)
|
)
|
||||||
}?.distinctBy { c -> c.url } ?: listOf()
|
}.distinctBy { c -> c.url }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
val doc = app.get(url).document
|
val doc = app.get(url).document
|
||||||
val body = doc.getElementsByTag("body")
|
val body = doc.getElementsByTag("body")
|
||||||
val inner = body?.select("div.info")
|
val inner = body.select("div.info")
|
||||||
|
|
||||||
// Video links
|
// Video links
|
||||||
val listOfLinks: MutableList<String> = mutableListOf()
|
val listOfLinks: MutableList<String> = mutableListOf()
|
||||||
|
@ -92,11 +94,11 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
var title = ""
|
var title = ""
|
||||||
var year: Int? = null
|
var year: Int? = null
|
||||||
var tags: List<String>? = null
|
var tags: List<String>? = null
|
||||||
val poster = fixUrlNull(inner?.select("div.portfolio-tumb.ph-link > img")?.attr("src"))
|
val poster = fixUrlNull(inner.select("div.portfolio-tumb.ph-link > img").attr("src"))
|
||||||
//Log.i(this.name, "Result => (imgLinkCode) ${imgLinkCode}")
|
//Log.i(this.name, "Result => (imgLinkCode) ${imgLinkCode}")
|
||||||
inner?.select("table")?.select("tr")?.forEach {
|
inner.select("table").select("tr").forEach {
|
||||||
val td = it?.select("td") ?: return@forEach
|
val td = it?.select("td") ?: return@forEach
|
||||||
val caption = td[0].text()?.lowercase()
|
val caption = td[0].text().lowercase()
|
||||||
//Log.i(this.name, "Result => (caption) $caption")
|
//Log.i(this.name, "Result => (caption) $caption")
|
||||||
when (caption) {
|
when (caption) {
|
||||||
"name" -> {
|
"name" -> {
|
||||||
|
@ -106,41 +108,45 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
var yearRes = td[1].toString()
|
var yearRes = td[1].toString()
|
||||||
year = if (yearRes.isNotBlank()) {
|
year = if (yearRes.isNotBlank()) {
|
||||||
if (yearRes.contains("var year =")) {
|
if (yearRes.contains("var year =")) {
|
||||||
yearRes = yearRes.substring(yearRes.indexOf("var year =") + "var year =".length)
|
yearRes =
|
||||||
|
yearRes.substring(yearRes.indexOf("var year =") + "var year =".length)
|
||||||
//Log.i(this.name, "Result => (yearRes) $yearRes")
|
//Log.i(this.name, "Result => (yearRes) $yearRes")
|
||||||
yearRes = yearRes.substring(0, yearRes.indexOf(';'))
|
yearRes = yearRes.substring(0, yearRes.indexOf(';'))
|
||||||
.trim().removeSurrounding("'")
|
.trim().removeSurrounding("'")
|
||||||
}
|
}
|
||||||
yearRes.toIntOrNull()
|
yearRes.toIntOrNull()
|
||||||
} else { null }
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"genre" -> {
|
"genre" -> {
|
||||||
tags = td[1].select("a")?.mapNotNull { tag ->
|
tags = td[1].select("a").mapNotNull { tag ->
|
||||||
tag?.text()?.trim() ?: return@mapNotNull null
|
tag?.text()?.trim() ?: return@mapNotNull null
|
||||||
}?.filter { a -> a.isNotBlank() }
|
}.filter { a -> a.isNotBlank() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var descript = body?.select("div.eText")?.text()
|
var descript = body.select("div.eText").text()
|
||||||
if (!descript.isNullOrEmpty()) {
|
if (!descript.isNullOrEmpty()) {
|
||||||
try {
|
try {
|
||||||
descript = "(undefined_x_Polus+[.\\d+])".toRegex().replace(descript, "")
|
descript = "(undefined_x_Polus+[.\\d+])".toRegex().replace(descript, "")
|
||||||
descript = "(_x_Polus+[.\\d+])".toRegex().replace(descript, "")
|
descript = "(_x_Polus+[.\\d+])".toRegex().replace(descript, "")
|
||||||
descript = descript.trim().removeSuffix("undefined").trim()
|
descript = descript.trim().removeSuffix("undefined").trim()
|
||||||
} catch (e: java.lang.Exception) { }
|
} catch (e: java.lang.Exception) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Add links hidden in description
|
// Add links hidden in description
|
||||||
listOfLinks.addAll(fetchUrls(descript))
|
listOfLinks.addAll(fetchUrls(descript))
|
||||||
listOfLinks.forEach { link ->
|
listOfLinks.forEach { link ->
|
||||||
//Log.i(this.name, "Result => (hidden link) $link")
|
//Log.i(this.name, "Result => (hidden link) $link")
|
||||||
descript = descript?.replace(link, "")
|
descript = descript.replace(link, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try looking for episodes, for series
|
// Try looking for episodes, for series
|
||||||
val episodeList = ArrayList<Episode>()
|
val episodeList = ArrayList<Episode>()
|
||||||
val bodyText = body?.select("div.section-cotent1.col-md-12")?.select("section")
|
val bodyText = body.select("div.section-cotent1.col-md-12").select("section")
|
||||||
?.select("script")?.toString() ?: ""
|
.select("script").toString()
|
||||||
//Log.i(this.name, "Result => (bodyText) ${bodyText}")
|
//Log.i(this.name, "Result => (bodyText) ${bodyText}")
|
||||||
|
|
||||||
"(?<=ses=\\(')(.*)(?='\\).split)".toRegex().find(bodyText)?.groupValues?.get(0).let {
|
"(?<=ses=\\(')(.*)(?='\\).split)".toRegex().find(bodyText)?.groupValues?.get(0).let {
|
||||||
|
@ -178,14 +184,14 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video links for Movie
|
// Video links for Movie
|
||||||
body?.select("div.tabcontent > iframe")?.forEach {
|
body.select("div.tabcontent > iframe").forEach {
|
||||||
val linkMain = it?.attr("src")
|
val linkMain = it?.attr("src")
|
||||||
if (!linkMain.isNullOrEmpty()) {
|
if (!linkMain.isNullOrEmpty()) {
|
||||||
listOfLinks.add(linkMain)
|
listOfLinks.add(linkMain)
|
||||||
//Log.i(this.name, "Result => (linkMain) $linkMain")
|
//Log.i(this.name, "Result => (linkMain) $linkMain")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body?.select("div.tabcontent.hide > iframe")?.forEach {
|
body.select("div.tabcontent.hide > iframe").forEach {
|
||||||
val linkMain = it?.attr("src")
|
val linkMain = it?.attr("src")
|
||||||
if (!linkMain.isNullOrEmpty()) {
|
if (!linkMain.isNullOrEmpty()) {
|
||||||
listOfLinks.add(linkMain)
|
listOfLinks.add(linkMain)
|
||||||
|
@ -193,7 +199,7 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val extraLinks = body?.select("div.tabcontent.hide")?.text()
|
val extraLinks = body.select("div.tabcontent.hide").text()
|
||||||
listOfLinks.addAll(fetchUrls(extraLinks))
|
listOfLinks.addAll(fetchUrls(extraLinks))
|
||||||
|
|
||||||
val streamLinks = listOfLinks.distinct().toJson()
|
val streamLinks = listOfLinks.distinct().toJson()
|
||||||
|
@ -218,7 +224,7 @@ class PinoyHDXyzProvider : MainAPI() {
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var count = 0
|
var count = 0
|
||||||
mapper.readValue<List<String>>(data).forEach { item ->
|
parseJson<List<String>>(data).forEach { item ->
|
||||||
val url = item.trim()
|
val url = item.trim()
|
||||||
if (url.isNotBlank()) {
|
if (url.isNotBlank()) {
|
||||||
if (loadExtractor(url, mainUrl, subtitleCallback, callback)) {
|
if (loadExtractor(url, mainUrl, subtitleCallback, callback)) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.lagradost.cloudstream3.movieproviders
|
package com.lagradost.cloudstream3.movieproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
|
@ -75,7 +75,7 @@ class VMoveeProvider : MainAPI() {
|
||||||
data = mapOf("action" to "doo_player_ajax", "post" to data, "nume" to "2", "type" to "movie")
|
data = mapOf("action" to "doo_player_ajax", "post" to data, "nume" to "2", "type" to "movie")
|
||||||
).text
|
).text
|
||||||
|
|
||||||
val ajax = mapper.readValue<LoadLinksAjax>(post)
|
val ajax = parseJson<LoadLinksAjax>(post)
|
||||||
var realUrl = ajax.embedUrl
|
var realUrl = ajax.embedUrl
|
||||||
if (realUrl.startsWith("//")) {
|
if (realUrl.startsWith("//")) {
|
||||||
realUrl = "https:$realUrl"
|
realUrl = "https:$realUrl"
|
||||||
|
@ -90,7 +90,7 @@ class VMoveeProvider : MainAPI() {
|
||||||
headers = mapOf("Referer" to request.url),
|
headers = mapOf("Referer" to request.url),
|
||||||
data = mapOf("r" to "https://www.vmovee.watch/", "d" to "reeoov.tube")
|
data = mapOf("r" to "https://www.vmovee.watch/", "d" to "reeoov.tube")
|
||||||
).text
|
).text
|
||||||
val apiData = mapper.readValue<ReeoovAPI>(apiResponse)
|
val apiData = parseJson<ReeoovAPI>(apiResponse)
|
||||||
for (d in apiData.data) {
|
for (d in apiData.data) {
|
||||||
callback.invoke(
|
callback.invoke(
|
||||||
ExtractorLink(
|
ExtractorLink(
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.lagradost.cloudstream3.movieproviders
|
package com.lagradost.cloudstream3.movieproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.animeproviders.GogoanimeProvider.Companion.extractVidstream
|
import com.lagradost.cloudstream3.animeproviders.GogoanimeProvider.Companion.extractVidstream
|
||||||
import com.lagradost.cloudstream3.extractors.XStreamCdn
|
import com.lagradost.cloudstream3.extractors.XStreamCdn
|
||||||
import com.lagradost.cloudstream3.extractors.helper.AsianEmbedHelper
|
import com.lagradost.cloudstream3.extractors.helper.AsianEmbedHelper
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
|
@ -208,7 +208,7 @@ class WatchAsianProvider : MainAPI() {
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
var count = 0
|
var count = 0
|
||||||
mapper.readValue<List<String>>(links).apmap { item ->
|
parseJson<List<String>>(links).apmap { item ->
|
||||||
count++
|
count++
|
||||||
val url = fixUrl(item.trim())
|
val url = fixUrl(item.trim())
|
||||||
//Log.i(this.name, "Result => (url) $url")
|
//Log.i(this.name, "Result => (url) $url")
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper
|
import com.fasterxml.jackson.databind.json.JsonMapper
|
||||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKeys
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKeys
|
||||||
|
@ -14,6 +13,7 @@ import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
||||||
import com.lagradost.cloudstream3.syncproviders.AuthAPI
|
import com.lagradost.cloudstream3.syncproviders.AuthAPI
|
||||||
import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.splitQuery
|
import com.lagradost.cloudstream3.utils.AppUtils.splitQuery
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
|
@ -174,9 +174,6 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val mapper = JsonMapper.builder().addModule(KotlinModule())
|
|
||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).build()!!
|
|
||||||
|
|
||||||
private val aniListStatusString =
|
private val aniListStatusString =
|
||||||
arrayOf("CURRENT", "COMPLETED", "PAUSED", "DROPPED", "PLANNING", "REPEATING")
|
arrayOf("CURRENT", "COMPLETED", "PAUSED", "DROPPED", "PLANNING", "REPEATING")
|
||||||
|
|
||||||
|
@ -489,7 +486,7 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
val data = postApi(q, true)
|
val data = postApi(q, true)
|
||||||
val d = mapper.readValue<GetDataRoot>(data ?: return null)
|
val d = parseJson<GetDataRoot>(data ?: return null)
|
||||||
|
|
||||||
val main = d.data?.Media
|
val main = d.data?.Media
|
||||||
if (main?.mediaListEntry != null) {
|
if (main?.mediaListEntry != null) {
|
||||||
|
@ -750,7 +747,7 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
}"""
|
}"""
|
||||||
val data = postApi(q)
|
val data = postApi(q)
|
||||||
if (data.isNullOrBlank()) return null
|
if (data.isNullOrBlank()) return null
|
||||||
val userData = mapper.readValue<AniListRoot>(data)
|
val userData = parseJson<AniListRoot>(data)
|
||||||
val u = userData.data?.Viewer
|
val u = userData.data?.Viewer
|
||||||
val user = AniListUser(
|
val user = AniListUser(
|
||||||
u?.id,
|
u?.id,
|
||||||
|
|
|
@ -2,10 +2,6 @@ package com.lagradost.cloudstream3.syncproviders.providers
|
||||||
|
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper
|
|
||||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
|
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
||||||
|
@ -16,6 +12,7 @@ import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
||||||
import com.lagradost.cloudstream3.syncproviders.AuthAPI
|
import com.lagradost.cloudstream3.syncproviders.AuthAPI
|
||||||
import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.splitQuery
|
import com.lagradost.cloudstream3.utils.AppUtils.splitQuery
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
@ -70,7 +67,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
"Authorization" to "Bearer $auth",
|
"Authorization" to "Bearer $auth",
|
||||||
), cacheTime = 0
|
), cacheTime = 0
|
||||||
).text
|
).text
|
||||||
return mapper.readValue<MalSearch>(res).data.map {
|
return parseJson<MalSearch>(res).data.map {
|
||||||
val node = it.node
|
val node = it.node
|
||||||
SyncAPI.SyncSearchResult(
|
SyncAPI.SyncSearchResult(
|
||||||
node.title,
|
node.title,
|
||||||
|
@ -196,7 +193,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
"Authorization" to "Bearer $auth"
|
"Authorization" to "Bearer $auth"
|
||||||
)
|
)
|
||||||
).text
|
).text
|
||||||
return mapper.readValue<MalAnime>(res).let { malAnime ->
|
return parseJson<MalAnime>(res).let { malAnime ->
|
||||||
SyncAPI.SyncResult(
|
SyncAPI.SyncResult(
|
||||||
id = internalId.toString(),
|
id = internalId.toString(),
|
||||||
totalEpisodes = malAnime.numEpisodes,
|
totalEpisodes = malAnime.numEpisodes,
|
||||||
|
@ -300,16 +297,13 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
openBrowser(request)
|
openBrowser(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val mapper = JsonMapper.builder().addModule(KotlinModule())
|
|
||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).build()!!
|
|
||||||
|
|
||||||
private var requestId = 0
|
private var requestId = 0
|
||||||
private var codeVerifier = ""
|
private var codeVerifier = ""
|
||||||
|
|
||||||
private fun storeToken(response: String) {
|
private fun storeToken(response: String) {
|
||||||
try {
|
try {
|
||||||
if (response != "") {
|
if (response != "") {
|
||||||
val token = mapper.readValue<ResponseToken>(response)
|
val token = parseJson<ResponseToken>(response)
|
||||||
setKey(accountId, MAL_UNIXTIME_KEY, (token.expires_in + unixTime))
|
setKey(accountId, MAL_UNIXTIME_KEY, (token.expires_in + unixTime))
|
||||||
setKey(accountId, MAL_REFRESH_TOKEN_KEY, token.refresh_token)
|
setKey(accountId, MAL_REFRESH_TOKEN_KEY, token.refresh_token)
|
||||||
setKey(accountId, MAL_TOKEN_KEY, token.access_token)
|
setKey(accountId, MAL_TOKEN_KEY, token.access_token)
|
||||||
|
@ -474,7 +468,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
), cacheTime = 0
|
), cacheTime = 0
|
||||||
).text
|
).text
|
||||||
|
|
||||||
return mapper.readValue<SmallMalAnime>(res)
|
return parseJson<SmallMalAnime>(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun setAllMalData() {
|
suspend fun setAllMalData() {
|
||||||
|
@ -490,7 +484,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
"Authorization" to "Bearer " + (getAuth() ?: return)
|
"Authorization" to "Bearer " + (getAuth() ?: return)
|
||||||
), cacheTime = 0
|
), cacheTime = 0
|
||||||
).text
|
).text
|
||||||
val values = mapper.readValue<MalRoot>(res)
|
val values = parseJson<MalRoot>(res)
|
||||||
val titles =
|
val titles =
|
||||||
values.data.map { MalTitleHolder(it.list_status, it.node.id, it.node.title) }
|
values.data.map { MalTitleHolder(it.list_status, it.node.id, it.node.title) }
|
||||||
for (t in titles) {
|
for (t in titles) {
|
||||||
|
@ -554,7 +548,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
), cacheTime = 0
|
), cacheTime = 0
|
||||||
).text
|
).text
|
||||||
|
|
||||||
val user = mapper.readValue<MalUser>(res)
|
val user = parseJson<MalUser>(res)
|
||||||
if (setSettings) {
|
if (setSettings) {
|
||||||
setKey(accountId, MAL_USER_KEY, user)
|
setKey(accountId, MAL_USER_KEY, user)
|
||||||
registerAccount()
|
registerAccount()
|
||||||
|
@ -600,7 +594,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
return if (res.isNullOrBlank()) {
|
return if (res.isNullOrBlank()) {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
val malStatus = mapper.readValue<MalStatus>(res)
|
val malStatus = parseJson<MalStatus>(res)
|
||||||
if (allTitles.containsKey(id)) {
|
if (allTitles.containsKey(id)) {
|
||||||
val currentTitle = allTitles[id]!!
|
val currentTitle = allTitles[id]!!
|
||||||
allTitles[id] = MalTitleHolder(malStatus, id, currentTitle.name)
|
allTitles[id] = MalTitleHolder(malStatus, id, currentTitle.name)
|
||||||
|
|
|
@ -10,10 +10,10 @@ import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.CommonActivity.showToast
|
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.getDefaultSharedPrefs
|
import com.lagradost.cloudstream3.utils.DataStore.getDefaultSharedPrefs
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.getSharedPrefs
|
import com.lagradost.cloudstream3.utils.DataStore.getSharedPrefs
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.mapper
|
import com.lagradost.cloudstream3.utils.DataStore.mapper
|
||||||
|
@ -152,7 +152,7 @@ object BackupUtils {
|
||||||
?: return@registerForActivityResult
|
?: return@registerForActivityResult
|
||||||
|
|
||||||
val restoredValue =
|
val restoredValue =
|
||||||
mapper.readValue<BackupFile>(input)
|
parseJson<BackupFile>(input.readBytes().toString())
|
||||||
activity.restore(
|
activity.restore(
|
||||||
restoredValue,
|
restoredValue,
|
||||||
restoreSettings = true,
|
restoreSettings = true,
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.app
|
import com.lagradost.cloudstream3.app
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
@ -65,9 +66,6 @@ class InAppUpdater {
|
||||||
@JsonProperty("updateNodeId") val updateNodeId: String?
|
@JsonProperty("updateNodeId") val updateNodeId: String?
|
||||||
)
|
)
|
||||||
|
|
||||||
private val mapper = JsonMapper.builder().addModule(KotlinModule())
|
|
||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).build()
|
|
||||||
|
|
||||||
private fun Activity.getAppUpdate(): Update {
|
private fun Activity.getAppUpdate(): Update {
|
||||||
return try {
|
return try {
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
@ -86,7 +84,7 @@ class InAppUpdater {
|
||||||
val url = "https://api.github.com/repos/LagradOst/CloudStream-3/releases"
|
val url = "https://api.github.com/repos/LagradOst/CloudStream-3/releases"
|
||||||
val headers = mapOf("Accept" to "application/vnd.github.v3+json")
|
val headers = mapOf("Accept" to "application/vnd.github.v3+json")
|
||||||
val response =
|
val response =
|
||||||
mapper.readValue<List<GithubRelease>>(runBlocking {
|
parseJson<List<GithubRelease>>(runBlocking {
|
||||||
app.get(
|
app.get(
|
||||||
url,
|
url,
|
||||||
headers = headers
|
headers = headers
|
||||||
|
@ -154,7 +152,7 @@ class InAppUpdater {
|
||||||
val releaseUrl = "https://api.github.com/repos/LagradOst/CloudStream-3/releases"
|
val releaseUrl = "https://api.github.com/repos/LagradOst/CloudStream-3/releases"
|
||||||
val headers = mapOf("Accept" to "application/vnd.github.v3+json")
|
val headers = mapOf("Accept" to "application/vnd.github.v3+json")
|
||||||
val response =
|
val response =
|
||||||
mapper.readValue<List<GithubRelease>>(app.get(releaseUrl, headers = headers).text)
|
parseJson<List<GithubRelease>>(app.get(releaseUrl, headers = headers).text)
|
||||||
|
|
||||||
val found =
|
val found =
|
||||||
response.lastOrNull { rel ->
|
response.lastOrNull { rel ->
|
||||||
|
@ -163,7 +161,7 @@ class InAppUpdater {
|
||||||
val foundAsset = found?.assets?.getOrNull(0)
|
val foundAsset = found?.assets?.getOrNull(0)
|
||||||
|
|
||||||
val tagResponse =
|
val tagResponse =
|
||||||
mapper.readValue<GithubTag>(app.get(tagUrl, headers = headers).text)
|
parseJson<GithubTag>(app.get(tagUrl, headers = headers).text)
|
||||||
|
|
||||||
val shouldUpdate =
|
val shouldUpdate =
|
||||||
(getString(R.string.prerelease_commit_hash) != tagResponse.github_object.sha)
|
(getString(R.string.prerelease_commit_hash) != tagResponse.github_object.sha)
|
||||||
|
|
|
@ -2,11 +2,10 @@ package com.lagradost.cloudstream3.utils
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
|
||||||
import com.lagradost.cloudstream3.animeproviders.AniflixProvider
|
import com.lagradost.cloudstream3.animeproviders.AniflixProvider
|
||||||
import com.lagradost.cloudstream3.app
|
import com.lagradost.cloudstream3.app
|
||||||
import com.lagradost.cloudstream3.mapper
|
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
object SyncUtil {
|
object SyncUtil {
|
||||||
|
@ -62,7 +61,7 @@ object SyncUtil {
|
||||||
val url =
|
val url =
|
||||||
"https://raw.githubusercontent.com/MALSync/MAL-Sync-Backup/master/data/pages/$site/$slug.json"
|
"https://raw.githubusercontent.com/MALSync/MAL-Sync-Backup/master/data/pages/$site/$slug.json"
|
||||||
val response = app.get(url, cacheTime = 1, cacheUnit = TimeUnit.DAYS).text
|
val response = app.get(url, cacheTime = 1, cacheUnit = TimeUnit.DAYS).text
|
||||||
val mapped = mapper.readValue<MalSyncPage?>(response)
|
val mapped = parseJson<MalSyncPage?>(response)
|
||||||
|
|
||||||
val overrideMal = mapped?.malId ?: mapped?.Mal?.id ?: mapped?.Anilist?.malId
|
val overrideMal = mapped?.malId ?: mapped?.Mal?.id ?: mapped?.Anilist?.malId
|
||||||
val overrideAnilist = mapped?.aniId ?: mapped?.Anilist?.id
|
val overrideAnilist = mapped?.aniId ?: mapped?.Anilist?.id
|
||||||
|
|
Loading…
Reference in a new issue