[Sora] removed Dub from Crunchy

This commit is contained in:
hexated 2022-12-22 14:01:10 +07:00
parent 64af3927d0
commit afa6956717
3 changed files with 27 additions and 24 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 61 version = 62
cloudstream { cloudstream {

View file

@ -1461,28 +1461,30 @@ object SoraExtractor : SoraStream() {
suspend fun invokeCrunchyroll( suspend fun invokeCrunchyroll(
title: String? = null, title: String? = null,
epsTitle: String? = null, epsTitle: String? = null,
season: Int? = null,
episode: Int? = null,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
val id = app.get("$consumetCrunchyrollAPI/$title") val id = app.get("$consumetCrunchyrollAPI/$title")
.parsedSafe<ConsumetSearchResponse>()?.results?.find { .parsedSafe<ConsumetSearchResponse>()?.results?.find {
it.title.equals( it.title.equals(
title, true title,
true
) && it.type.equals("series") ) && it.type.equals("series")
} ?: return } ?: return
val detail = app.get("$consumetCrunchyrollAPI/info?id=${id.id}&mediaType=series").text val detail = app.get("$consumetCrunchyrollAPI/info?id=${id.id}&mediaType=series").text
val episodeId = tryParseJson<ConsumetDetails>(detail)?.episodes?.filter { val episodeId = tryParseJson<ConsumetDetails>(detail)?.episodes?.filter {
it.title.equals(epsTitle, true) && (it.type == "Subbed" || it.type == "English Dub") (it.number == episode || it.title.equals(epsTitle, true)) && it.type == "Subbed"
}?.map { it.id to it.type } ?: return }?.map { it.id }?.getOrNull(season?.minus(1) ?: 0) ?: return
episodeId.apmap { (id, type) -> val json = app.get("$consumetCrunchyrollAPI/watch?episodeId=$episodeId&format=srt")
val json = app.get("$consumetCrunchyrollAPI/watch?episodeId=$id&format=srt")
.parsedSafe<ConsumetSourcesResponse>() .parsedSafe<ConsumetSourcesResponse>()
json?.sources?.map source@{ source -> json?.sources?.map source@{ source ->
M3u8Helper.generateM3u8( M3u8Helper.generateM3u8(
"Crunchyroll [$type]", "Crunchyroll",
source.url ?: return@source null, source.url ?: return@source null,
"", "",
).forEach(callback) ).forEach(callback)
@ -1497,7 +1499,6 @@ object SoraExtractor : SoraStream() {
) )
} }
}
} }

View file

@ -351,6 +351,8 @@ open class SoraStream : TmdbProvider() {
if (res.season != null && res.isAnime) invokeCrunchyroll( if (res.season != null && res.isAnime) invokeCrunchyroll(
res.title, res.title,
res.epsTitle, res.epsTitle,
res.season,
res.episode,
subtitleCallback, subtitleCallback,
callback callback
) )