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): update subtitle fetching #3013

Merged
merged 1 commit into from
Mar 6, 2024
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
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