Skip to content
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

Merged
merged 13 commits into from
May 4, 2024

Conversation

rushi-chavan
Copy link
Contributor

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(.....)

rushi-chavan and others added 4 commits April 12, 2024 01:53
+ new AnyVidplay extractor which can be used on alternate vidplay domains by AnyVidplay(<new doamin>),getUrl(...)
@rushi-chavan
Copy link
Contributor Author

@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
Copy link
Collaborator

@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)
    }
}

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.
@rushi-chavan
Copy link
Contributor Author

@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. c363596
Please have a look at this as well.

Copy link
Collaborator

@fire-light42 fire-light42 left a 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)
Copy link
Collaborator

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.

@fire-light42
Copy link
Collaborator

Your commit to the TmdbProvider looks good, but I dont see the pr.

Copy link
Collaborator

@fire-light42 fire-light42 left a 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

@rushi-chavan
Copy link
Contributor Author

Good to go

@fire-light42 fire-light42 merged commit c28a3cb into recloudstream:master May 4, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants