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

fix(en): fix vidsrc extractor + vrf helper #2363

Merged
merged 3 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/en/fmovies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
extName = 'FMovies'
pkgNameSuffix = 'en.fmovies'
extClass = '.FMovies'
extVersionCode = 10
extVersionCode = 11
libVersion = '13'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FMoviesHelper(private val client: OkHttpClient, private val headers: Heade

fun getVidSrc(query: String, host: String): String {
val url = API_URL.newBuilder().apply {
addPathSegment(if (host == "vidstream.pro") "rawVizcloud" else "rawMcloud")
addPathSegment(if (host.contains("mcloud", true)) "rawMcloud" else "rawVizcloud")
addQueryParameter("apikey", API_KEY)
}.build().toString()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,64 @@ class VidsrcExtractor(private val client: OkHttpClient, private val headers: Hea
private val playlistUtils by lazy { PlaylistUtils(client, headers) }

fun videosFromUrl(url: String, name: String): List<Video> {
val host = when (name) {
"Vidplay" -> "vidstream.pro"
else -> "mcloud.to"
}
val httpUrl = url.toHttpUrl()
val host = httpUrl.host
val referer = "https://$host/"

val httpUrl = url.toHttpUrl()
val query = buildString {
append(httpUrl.pathSegments.last())
append("?")
append(
httpUrl.queryParameterNames.joinToString("&") {
"$it=${httpUrl.queryParameter(it)}"
},
)
}

val query = "${httpUrl.pathSegments.last()}?t=${httpUrl.queryParameter("t")!!}"
val rawUrl = vrfHelper.getVidSrc(query, host)
val rawUrl = vrfHelper.getVidSrc(query, host).addAutoStart()

val refererHeaders = headers.newBuilder().apply {
add("Referer", referer)
add("Accept", "application/json, text/javascript, */*; q=0.01")
add("Host", host)
add("Referer", url.addAutoStart())
add("X-Requested-With", "XMLHttpRequest")
}.build()

val infoJson = client.newCall(
GET(rawUrl, headers = refererHeaders),
).execute().parseAs<VidsrcResponse>()

val subtitleList = httpUrl.queryParameter("sub.info")?.let {
val subtitlesHeaders = headers.newBuilder().apply {
add("Accept", "application/json, text/javascript, */*; q=0.01")
add("Host", it.toHttpUrl().host)
add("Origin", "https://$host")
add("Referer", referer)
}.build()

client.newCall(
GET(it, headers = refererHeaders),
GET(it, headers = subtitlesHeaders),
).execute().parseAs<List<FMoviesSubs>>().map {
Track(it.file, it.label)
}
} ?: emptyList()

return infoJson.result.sources.distinctBy { it.file }.flatMap {
playlistUtils.extractFromHls(it.file, subtitleList = subtitleList, referer = referer, videoNameGen = { q -> "$name - $q" })
val url = it.file
.toHttpUrl()
.newBuilder()
.fragment(null)
.build()
.toString()

playlistUtils.extractFromHls(url, subtitleList = subtitleList, referer = referer, videoNameGen = { q -> "$name - $q" })
}
}

private fun String.addAutoStart(): String {
return this.toHttpUrl().newBuilder().setQueryParameter("autostart", "true").build().toString()
}

private inline fun <reified T> Response.parseAs(transform: (String) -> String = { it }): T {
val responseBody = use { transform(it.body.string()) }
return json.decodeFromString(responseBody)
Expand Down
2 changes: 1 addition & 1 deletion src/en/seez/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
extName = 'Seez'
pkgNameSuffix = 'en.seez'
extClass = '.Seez'
extVersionCode = 3
extVersionCode = 4
libVersion = '13'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class VrfHelper(private val client: OkHttpClient, private val headers: Headers)

fun getVidSrc(query: String, host: String): String {
val url = API_URL.newBuilder().apply {
addPathSegment("rawVizcloud")
addPathSegment(if (host.contains("mcloud", true)) "rawMcloud" else "rawVizcloud")
addQueryParameter("apikey", API_KEY)
}.build().toString()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,64 @@ class VidsrcExtractor(private val client: OkHttpClient, private val headers: Hea
private val playlistUtils by lazy { PlaylistUtils(client, headers) }

fun videosFromUrl(url: String, name: String): List<Video> {
val host = "vidstream.pro"

val httpUrl = url.toHttpUrl()
val host = httpUrl.host
val referer = "https://$host/"

val httpUrl = url.toHttpUrl()
val query = buildString {
append(httpUrl.pathSegments.last())
append("?")
append(
httpUrl.queryParameterNames.joinToString("&") {
"$it=${httpUrl.queryParameter(it)}"
},
)
}

val query = "${httpUrl.pathSegments.last()}?t=${httpUrl.queryParameter("t")!!}"
val rawUrl = vrfHelper.getVidSrc(query, host)
val rawUrl = vrfHelper.getVidSrc(query, host).addAutoStart()

val refererHeaders = headers.newBuilder().apply {
add("Referer", referer)
add("Accept", "application/json, text/javascript, */*; q=0.01")
add("Host", host)
add("Referer", url.addAutoStart())
add("X-Requested-With", "XMLHttpRequest")
}.build()

val infoJson = client.newCall(
GET(rawUrl, headers = refererHeaders),
).execute().parseAs<VidsrcResponse>()

val subtitleList = httpUrl.queryParameter("sub.info")?.let {
val subtitlesHeaders = headers.newBuilder().apply {
add("Accept", "application/json, text/javascript, */*; q=0.01")
add("Host", it.toHttpUrl().host)
add("Origin", "https://$host")
add("Referer", referer)
}.build()

client.newCall(
GET(it, headers = refererHeaders),
GET(it, headers = subtitlesHeaders),
).execute().parseAs<List<FMoviesSubs>>().map {
Track(it.file, it.label)
}
} ?: emptyList()

return infoJson.result.sources.distinctBy { it.file }.flatMap {
playlistUtils.extractFromHls(it.file, subtitleList = subtitleList, referer = referer, videoNameGen = { q -> "$name - $q" })
val url = it.file
.toHttpUrl()
.newBuilder()
.fragment(null)
.build()
.toString()

playlistUtils.extractFromHls(url, subtitleList = subtitleList, referer = referer, videoNameGen = { q -> "$name - $q" })
}
}

private fun String.addAutoStart(): String {
return this.toHttpUrl().newBuilder().setQueryParameter("autostart", "true").build().toString()
}

private inline fun <reified T> Response.parseAs(transform: (String) -> String = { it }): T {
val responseBody = use { transform(it.body.string()) }
return json.decodeFromString(responseBody)
Expand Down