Skip to content

Commit

Permalink
fix(en/fmovies): Use correct action for mcloud and small tweak to fil…
Browse files Browse the repository at this point in the history
…ters (#2231)
  • Loading branch information
Secozzi authored Sep 21, 2023
1 parent cf721b6 commit 5aee7f6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 50 deletions.
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

0 comments on commit 5aee7f6

Please sign in to comment.