-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extractor: new VidSrcTo extractor #1044
Conversation
+ new AnyVidplay extractor which can be used on alternate vidplay domains by AnyVidplay(<new doamin>),getUrl(...)
app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcTo.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcTo.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcTo.kt
Outdated
Show resolved
Hide resolved
@fire-light42 can you please have a look now? |
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)
}
} |
This data is passed to loadLinks but name is not included in TvSeriesLoadResponse which is crucial as not all sites support filtering using ids and name is required.
@fire-light42 Thank you so much for telling me how to flat the code> I really appreciate your help. Also, I am including another change related to TmdbProvider in this PR. c363596 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks fine, just want to make sure that it can handle an extra edgecase
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not catch this in the first review, however when looking at the code a bit more, can this at any point cause an infinite loop? If it can, detect it and throw an exception/return.
We can catch exceptions, but not inf recursion. Can you just do a assert(finalUrl != url) or smth along those lines.
Your commit to the TmdbProvider looks good, but I dont see the pr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you fixed it, comment or react with 👍 to get this merged
Good to go |
This also creates NewVidplay extractor which is adaptive as you can pass hostUrl to it before calling getUrl to migrate changing domain URLs.
NewVidplay().getUrl(.....)