[Sora] fixed Crunchyroll

This commit is contained in:
hexated 2023-01-19 09:51:04 +07:00
parent e61f39b11f
commit 65c3ff8d2e
4 changed files with 49 additions and 21 deletions

View file

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

View file

@ -1369,10 +1369,10 @@ object SoraExtractor : SoraStream() {
}
val videoQuality =
Regex("\\d{3,4}p\\.?(.*?)\\[").find(quality)?.groupValues?.getOrNull(1)?.trim()
Regex("\\d{3,4}[Pp]\\.?(.*?)\\[").find(quality)?.groupValues?.getOrNull(1)?.trim()
?: ""
val qualities =
Regex("(\\d{3,4})p").find(quality)?.groupValues?.getOrNull(1)?.toIntOrNull()
Regex("(\\d{3,4})[Pp]").find(quality)?.groupValues?.getOrNull(1)?.toIntOrNull()
?: Qualities.Unknown.value
val size =
Regex("(?i)\\[(\\S+\\s?(gb|mb))[]/]").find(quality)?.groupValues?.getOrNull(1)
@ -1674,38 +1674,40 @@ object SoraExtractor : SoraStream() {
} ?: return
val detail = app.get("$consumetCrunchyrollAPI/info?id=${id.id}&mediaType=series").text
val episodeId = tryParseJson<ConsumetDetails>(detail)?.episodes?.filter {
(it.number == episode || it.title.equals(epsTitle, true))
}?.let { eps ->
listOf(eps.filter { it.type == "Subbed" }.map { it.id }
.getOrNull(season?.minus(1) ?: 0) to "Subbed",
eps.filter { it.type == "English Dub" }.map { it.id }
.getOrNull(season?.minus(1) ?: 0) to "English Dub")
}
val epsId = tryParseJson<CrunchyrollDetails>(detail)?.findCrunchyrollId(
title,
season,
episode,
epsTitle
) ?: return
episodeId?.apmap { (id, type) ->
epsId.apmap {
val json =
app.get("$consumetCrunchyrollAPI/watch?episodeId=${id ?: return@apmap null}&format=srt")
app.get("$consumetCrunchyrollAPI/watch?episodeId=${it?.first ?: return@apmap null}")
.parsedSafe<ConsumetSourcesResponse>()
json?.sources?.map source@{ source ->
M3u8Helper.generateM3u8(
"Crunchyroll [$type]",
source.url ?: return@source null,
"",
).forEach(callback)
callback.invoke(
ExtractorLink(
"Crunchyroll [${it.second ?: ""}]",
"Crunchyroll [${it.second ?: ""}]",
source.url ?: return@source null,
"https://static.crunchyroll.com/",
getQualityFromName(source.quality),
true
)
)
}
json?.subtitles?.map subtitle@{ sub ->
subtitleCallback.invoke(
SubtitleFile(
sub.lang?.replace(Regex("\\[\\S+]"), "")?.trim() ?: "",
sub.lang ?: "",
sub.url ?: return@subtitle null
)
)
}
}
}
suspend fun invokeMoviesbay(
@ -2151,6 +2153,10 @@ data class ConsumetDetails(
@JsonProperty("episodes") val episodes: ArrayList<ConsumetEpisodes>? = arrayListOf(),
)
data class CrunchyrollDetails(
@JsonProperty("episodes") val episodes: HashMap<String, List<HashMap<String, String>>>? = hashMapOf(),
)
data class ConsumetResults(
@JsonProperty("id") val id: String? = null,
@JsonProperty("title") val title: String? = null,

View file

@ -92,7 +92,7 @@ open class SoraStream : TmdbProvider() {
const val uhdmoviesAPI = "https://uhdmovies.org.in"
const val fwatayakoAPI = "https://5100.svetacdn.in"
const val gMoviesAPI = "https://gdrivemovies.xyz"
const val fdMoviesAPI = "https://freedrivemovie.com"
const val fdMoviesAPI = "https://freedrivemovie.lol"
const val m4uhdAPI = "https://m4uhd.tv"
const val tvMoviesAPI = "https://www.tvseriesnmovies.com"
const val moviezAddAPI = "https://m.bloginguru.info"

View file

@ -468,6 +468,28 @@ fun Document.findTvMoviesIframe(): String? {
?.substringBefore("'>")
}
fun CrunchyrollDetails.findCrunchyrollId(
title: String?,
season: Int?,
episode: Int?,
epsTitle: String?
): List<Pair<String?, String?>?> {
val sub = when (title) {
"One Piece" -> this.episodes?.get("subbed13")?.matchingEpisode(episode) to "Raw"
"Hunter x Hunter" -> this.episodes?.get("subbed5")?.matchingEpisode(episode) to "Raw"
else -> this.episodes?.get("subbed$season")?.matchingEpisode(episode) to "Raw"
}
val dub = this.episodes?.get("English Dub$season")?.matchingEpisode(episode) to "English Dub"
return listOf(sub, dub)
}
fun List<HashMap<String, String>>?.matchingEpisode(episode: Int?): String? {
return this?.find {
it["episode_number"] == "$episode"
}?.get("id")
}
fun String?.fixTitle(): String? {
return this?.replace(Regex("[!%:'?]|( &)"), "")?.replace(" ", "-")?.lowercase()
?.replace("--", "-")