sora: fix WatchOnline subtitle

This commit is contained in:
hexated 2023-03-14 02:13:38 +07:00
parent 60f54a4ab7
commit 81d9a82701
3 changed files with 33 additions and 15 deletions

View file

@ -582,8 +582,8 @@ object SoraExtractor : SoraStream() {
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
"Filmxy $size ($server)", "Filmxy",
"Filmxy $size ($server)", "Filmxy $server [$size]",
link ?: return@map, link ?: return@map,
"$filmxyAPI/", "$filmxyAPI/",
getQualityFromName(quality) getQualityFromName(quality)
@ -1791,6 +1791,7 @@ object SoraExtractor : SoraStream() {
?.attr("onclick") ?.attr("onclick")
?.substringAfter("('")?.substringBefore("')") ?.substringAfter("('")?.substringBefore("')")
delay(1000)
val unPacker = val unPacker =
app.get( app.get(
iframe ?: return, iframe ?: return,
@ -2710,13 +2711,13 @@ object SoraExtractor : SoraStream() {
} }
//TODO add subtitle
suspend fun invokeWatchOnline( suspend fun invokeWatchOnline(
imdbId: String? = null, imdbId: String? = null,
title: String? = null, title: String? = null,
year: Int? = null, year: Int? = null,
season: Int? = null, season: Int? = null,
episode: Int? = null, episode: Int? = null,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit, callback: (ExtractorLink) -> Unit,
) { ) {
val slug = title.createSlug() val slug = title.createSlug()
@ -2742,8 +2743,10 @@ object SoraExtractor : SoraStream() {
"$watchOnlineAPI/api/v1/security/episode-access?id=$episodeId" "$watchOnlineAPI/api/v1/security/episode-access?id=$episodeId"
} }
app.get(videoUrl, referer = url) val json = app.get(videoUrl, referer = url)
.parsedSafe<WatchOnlineResponse>()?.streams?.mapKeys { source -> .parsedSafe<WatchOnlineResponse>()
json?.streams?.mapKeys { source ->
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
"WatchOnline", "WatchOnline",
@ -2756,6 +2759,18 @@ object SoraExtractor : SoraStream() {
) )
} }
//TODO find better way
val subtitles = json?.subtitles as ArrayList<HashMap<String, String>>
subtitles.map { sub ->
subtitleCallback.invoke(
SubtitleFile(
sub["language"] ?: return@map,
fixUrl(sub["url"] ?: return@map, watchOnlineAPI)
)
)
}
} }
@ -3141,4 +3156,5 @@ data class BiliBiliSourcesResponse(
data class WatchOnlineResponse( data class WatchOnlineResponse(
@JsonProperty("streams") val streams: HashMap<String, String>? = null, @JsonProperty("streams") val streams: HashMap<String, String>? = null,
@JsonProperty("subtitles") val subtitles: Any? = null,
) )

View file

@ -796,6 +796,7 @@ open class SoraStream : TmdbProvider() {
res.airedYear ?: res.year, res.airedYear ?: res.year,
res.season, res.season,
res.episode, res.episode,
subtitleCallback,
callback callback
) )
}, },

View file

@ -230,6 +230,7 @@ class SoraStreamLite : SoraStream() {
res.airedYear ?: res.year, res.airedYear ?: res.year,
res.season, res.season,
res.episode, res.episode,
subtitleCallback,
callback callback
) )
}, },