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/fmovies): use correct action for mcloud and small tweak to filters #2231

Merged
merged 1 commit into from
Sep 21, 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 = 7
extVersionCode = 8
libVersion = '13'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,50 +216,43 @@ class FMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
response.parseAs<AjaxResponse>().result,
)
val hosterSelection = preferences.getStringSet(PREF_HOSTER_KEY, PREF_HOSTER_DEFAULT)!!
val videoList = mutableListOf<Video>()

videoList.addAll(
document.select("ul.servers > li.server").parallelMap { server ->
runCatching {
val name = server.text().trim()
if (!hosterSelection.contains(name)) return@runCatching null

// Get decrypted url
val vrf = vrfHelper.getVrf(server.attr("data-link-id"))

val vrfHeaders = headers.newBuilder()
.add("Accept", "application/json, text/javascript, */*; q=0.01")
.add("Host", baseUrl.toHttpUrl().host)
.add("Referer", data.url)
.add("X-Requested-With", "XMLHttpRequest")
.build()
val encrypted = client.newCall(
GET("$baseUrl/ajax/server/${server.attr("data-link-id")}?vrf=$vrf", headers = vrfHeaders),
).execute().parseAs<AjaxServerResponse>().result.url

val decrypted = vrfHelper.decrypt(encrypted)

when (name) {
"Vidplay", "MyCloud" -> vidsrcExtractor.videosFromUrl(decrypted, name)
"Filemoon" -> filemoonExtractor.videosFromUrl(decrypted, headers = headers)
"Streamtape" -> {
val subtitleList = decrypted.toHttpUrl().queryParameter("sub.info")?.let {
client.newCall(GET(it, headers)).execute().parseAs<List<FMoviesSubs>>().map { t ->
Track(t.file, t.label)
}
} ?: emptyList()

streamtapeExtractor.videoFromUrl(decrypted, subtitleList = subtitleList)?.let(::listOf) ?: emptyList()
}
else -> null
}
}.getOrNull()
}.filterNotNull().flatten(),
)

require(videoList.isNotEmpty()) { "Failed to fetch videos" }

return videoList.sort()
return document.select("ul.servers > li.server").parallelMap { server ->
runCatching {
val name = server.text().trim()
if (!hosterSelection.contains(name)) return@runCatching emptyList()

// Get decrypted url
val vrf = vrfHelper.getVrf(server.attr("data-link-id"))

val vrfHeaders = headers.newBuilder()
.add("Accept", "application/json, text/javascript, */*; q=0.01")
.add("Host", baseUrl.toHttpUrl().host)
.add("Referer", data.url)
.add("X-Requested-With", "XMLHttpRequest")
.build()
val encrypted = client.newCall(
GET("$baseUrl/ajax/server/${server.attr("data-link-id")}?vrf=$vrf", headers = vrfHeaders),
).execute().parseAs<AjaxServerResponse>().result.url

val decrypted = vrfHelper.decrypt(encrypted)

when (name) {
"Vidplay", "MyCloud" -> vidsrcExtractor.videosFromUrl(decrypted, name)
"Filemoon" -> filemoonExtractor.videosFromUrl(decrypted, headers = headers)
"Streamtape" -> {
val subtitleList = decrypted.toHttpUrl().queryParameter("sub.info")?.let {
client.newCall(GET(it, headers)).execute().parseAs<List<FMoviesSubs>>().map { t ->
Track(t.file, t.label)
}
} ?: emptyList()

streamtapeExtractor.videoFromUrl(decrypted, subtitleList = subtitleList)?.let(::listOf) ?: emptyList()
}
else -> emptyList()
}
}.getOrElse { emptyList() }
}.flatten().ifEmpty { throw Exception("Failed to fetch videos") }
}

override fun videoListSelector() = throw Exception("not used")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ object FMoviesFilters {
)

val SORT = arrayOf(
Pair("Most relevance", "most_relevance"),
Pair("Recently updated", "recently_updated"),
Pair("Recently added", "recently_added"),
Pair("Release date", "release_date"),
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("rawVizcloud")
addPathSegment(if (host == "vidstream.pro") "rawVizcloud" else "rawMcloud")
addQueryParameter("apikey", API_KEY)
}.build().toString()

Expand All @@ -52,13 +52,9 @@ class FMoviesHelper(private val client: OkHttpClient, private val headers: Heade
add("futoken", futoken)
}.build()

val rawURL = client.newCall(
return client.newCall(
POST(url, body = body),
).execute().parseAs<RawResponse>().rawURL

return rawURL.toHttpUrl().newBuilder().apply {
host(host)
}.build().toString()
}

companion object {
Expand Down