[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 // use an integer for version numbers
version = 74 version = 75
cloudstream { cloudstream {

View File

@ -1369,10 +1369,10 @@ object SoraExtractor : SoraStream() {
} }
val videoQuality = 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 = 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 ?: Qualities.Unknown.value
val size = val size =
Regex("(?i)\\[(\\S+\\s?(gb|mb))[]/]").find(quality)?.groupValues?.getOrNull(1) Regex("(?i)\\[(\\S+\\s?(gb|mb))[]/]").find(quality)?.groupValues?.getOrNull(1)
@ -1674,38 +1674,40 @@ object SoraExtractor : SoraStream() {
} ?: 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 epsId = tryParseJson<CrunchyrollDetails>(detail)?.findCrunchyrollId(
(it.number == episode || it.title.equals(epsTitle, true)) title,
}?.let { eps -> season,
listOf(eps.filter { it.type == "Subbed" }.map { it.id } episode,
.getOrNull(season?.minus(1) ?: 0) to "Subbed", epsTitle
eps.filter { it.type == "English Dub" }.map { it.id } ) ?: return
.getOrNull(season?.minus(1) ?: 0) to "English Dub")
}
episodeId?.apmap { (id, type) -> epsId.apmap {
val json = 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>() .parsedSafe<ConsumetSourcesResponse>()
json?.sources?.map source@{ source -> json?.sources?.map source@{ source ->
M3u8Helper.generateM3u8( callback.invoke(
"Crunchyroll [$type]", ExtractorLink(
source.url ?: return@source null, "Crunchyroll [${it.second ?: ""}]",
"", "Crunchyroll [${it.second ?: ""}]",
).forEach(callback) source.url ?: return@source null,
"https://static.crunchyroll.com/",
getQualityFromName(source.quality),
true
)
)
} }
json?.subtitles?.map subtitle@{ sub -> json?.subtitles?.map subtitle@{ sub ->
subtitleCallback.invoke( subtitleCallback.invoke(
SubtitleFile( SubtitleFile(
sub.lang?.replace(Regex("\\[\\S+]"), "")?.trim() ?: "", sub.lang ?: "",
sub.url ?: return@subtitle null sub.url ?: return@subtitle null
) )
) )
} }
} }
} }
suspend fun invokeMoviesbay( suspend fun invokeMoviesbay(
@ -2151,6 +2153,10 @@ data class ConsumetDetails(
@JsonProperty("episodes") val episodes: ArrayList<ConsumetEpisodes>? = arrayListOf(), @JsonProperty("episodes") val episodes: ArrayList<ConsumetEpisodes>? = arrayListOf(),
) )
data class CrunchyrollDetails(
@JsonProperty("episodes") val episodes: HashMap<String, List<HashMap<String, String>>>? = hashMapOf(),
)
data class ConsumetResults( data class ConsumetResults(
@JsonProperty("id") val id: String? = null, @JsonProperty("id") val id: String? = null,
@JsonProperty("title") val title: 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 uhdmoviesAPI = "https://uhdmovies.org.in"
const val fwatayakoAPI = "https://5100.svetacdn.in" const val fwatayakoAPI = "https://5100.svetacdn.in"
const val gMoviesAPI = "https://gdrivemovies.xyz" 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 m4uhdAPI = "https://m4uhd.tv"
const val tvMoviesAPI = "https://www.tvseriesnmovies.com" const val tvMoviesAPI = "https://www.tvseriesnmovies.com"
const val moviezAddAPI = "https://m.bloginguru.info" const val moviezAddAPI = "https://m.bloginguru.info"

View File

@ -468,6 +468,28 @@ fun Document.findTvMoviesIframe(): String? {
?.substringBefore("'>") ?.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? { fun String?.fixTitle(): String? {
return this?.replace(Regex("[!%:'?]|( &)"), "")?.replace(" ", "-")?.lowercase() return this?.replace(Regex("[!%:'?]|( &)"), "")?.replace(" ", "-")?.lowercase()
?.replace("--", "-") ?.replace("--", "-")