Extractor: new VidSrcTo extractor
This also creates NewVidplay extractor which is adaptive as you can pass hostUrl to it before calling getUrl to migrate changing domain URLs.
NewVidplay(
@fire-light42 can you please have a look now?
I tried to reduce few if statements but if(status == 200) seems mandatory cause there is nothing to return when status != 200.
so I don't understand the need of if (res.status != 200) return
@fire-light42 can you please have a look now? I tried to reduce few if statements but if(status == 200) seems mandatory cause there is nothing to return when status != 200. so I don't understand the need of
if (res.status != 200) return
You want to flatten the code as much as possible, here is an example on how I would do it
app.get(url).document.selectFirst("ul.episodes li a")?.attr("data-id")?.let { mediaId ->
val res = app.get("$mainUrl/ajax/embed/episode/$mediaId/sources").parsedSafe<VidsrctoEpisodeSources>()
if (res?.status == 200) {
res.result?.amap { source ->
val embedRes = app.get("$mainUrl/ajax/embed/source/${source.id}").parsedSafe<VidsrctoEmbedSource>()
val finalUrl = DecryptUrl(embedRes?.result?.encUrl ?: "")
when (source.title) {
"Vidplay" -> AnyVidplay(finalUrl.substringBefore("/e/")).getUrl(finalUrl, referer, subtitleCallback, callback)
"Filemoon" -> FileMoon().getUrl(finalUrl, referer, subtitleCallback, callback)
}
}
}
}
into
val mediaId = app.get(url).document.selectFirst("ul.episodes li a")?.attr("data-id") ?: return
val res = app.get("$mainUrl/ajax/embed/episode/$mediaId/sources").parsedSafe<VidsrctoEpisodeSources>() ?: return
if (res.status != 200) return
res.result?.amap { source ->
val embedRes = app.get("$mainUrl/ajax/embed/source/${source.id}").parsedSafe<VidsrctoEmbedSource>() ?: return@amap
val finalUrl = DecryptUrl(embedRes.result.encUrl)
when (source.title) {
"Vidplay" -> AnyVidplay(finalUrl.substringBefore("/e/")).getUrl(finalUrl, referer, subtitleCallback, callback)
"Filemoon" -> FileMoon().getUrl(finalUrl, referer, subtitleCallback, callback)
}
}
@fire-light42 Thank you so much for telling me how to flat the code> I really appreciate your help. Please have a look at the updated changes and let me know if any issue with it.
Also, I am including another change related to TmdbProvider in this PR. https://github.com/recloudstream/cloudstream/pull/1044/commits/c363596d4f7fbf7afcd9ff5cf0cc2efff7e4ad85 Please have a look at this as well.
Your commit to the TmdbProvider looks good, but I dont see the pr.
Good to go