Skip to content

Commit

Permalink
fix(en/fmovies): Update subtitle fetching (#3013)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samfun75 authored Mar 6, 2024
1 parent 39fba62 commit 40811bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class VidsrcExtractor(private val client: OkHttpClient, private val headers: Hea
).execute().parseAs<List<String>>()
}

fun videosFromUrl(embedLink: String, hosterName: String, type: String = ""): List<Video> {
fun videosFromUrl(embedLink: String, hosterName: String, type: String = "", subtitleList: List<Track> = emptyList()): List<Video> {
val host = embedLink.toHttpUrl().host
val apiUrl = getApiUrl(embedLink, keys)

Expand Down Expand Up @@ -64,7 +64,7 @@ class VidsrcExtractor(private val client: OkHttpClient, private val headers: Hea
data.result.sources.first().file,
referer = "https://$host/",
videoNameGen = { q -> hosterName + (if (type.isBlank()) "" else " - $type") + " - $q" },
subtitleList = data.result.tracks.toTracks(),
subtitleList = subtitleList + data.result.tracks.toTracks(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,16 @@ class FMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

val decrypted = utils.vrfDecrypt(encrypted)
when (name) {
"Vidplay", "MyCloud" -> vidsrcExtractor.videosFromUrl(decrypted, name)
"Vidplay", "MyCloud" -> {
val subs = client.newCall(
GET("$baseUrl/ajax/episode/subtitles/${data.id}"),
).execute().toTracks()
vidsrcExtractor.videosFromUrl(decrypted, name, subtitleList = subs)
}
"Filemoon" -> filemoonExtractor.videosFromUrl(decrypted, headers = headers)
"Streamtape" -> {
val subtitleList = decrypted.toHttpUrl().queryParameter("sub.info")?.let {
client.newCall(GET(it, headers)).await().parseAs<List<FMoviesSubs>>().map { t ->
Track(t.file, t.label)
}
client.newCall(GET(it, headers)).await().toTracks()
} ?: emptyList()

streamtapeExtractor.videoFromUrl(decrypted, subtitleList = subtitleList)?.let(::listOf) ?: emptyList()
Expand Down Expand Up @@ -292,6 +295,11 @@ class FMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
return if (this == 1) "" else "${if (first) "?" else "&"}page=$this"
}

private fun Response.toTracks(): List<Track> = parseAs<List<FMoviesSubs>>()
.map { t ->
Track(t.file, t.label)
}

companion object {
private val HOSTERS = arrayOf(
"Vidplay",
Expand Down

0 comments on commit 40811bc

Please sign in to comment.