🎉 ruin sora with dub

This commit is contained in:
hexated 2022-12-23 19:02:01 +07:00
parent afa6956717
commit ebb89face3
3 changed files with 58 additions and 49 deletions

View file

@ -1014,31 +1014,36 @@ object SoraExtractor : SoraStream() {
val episodeId = app.get("$consumetAnilistAPI/info/$anilistId?provider=zoro") val episodeId = app.get("$consumetAnilistAPI/info/$anilistId?provider=zoro")
.parsedSafe<ConsumetDetails>()?.episodes?.find { .parsedSafe<ConsumetDetails>()?.episodes?.find {
it.number == episode it.number == episode
}?.id ?: return }?.id?.substringBeforeLast("$") ?: return
val sources = app.get("$consumetZoroAPI/watch?episodeId=$episodeId", timeout = 120L) listOf(
.parsedSafe<ConsumetSourcesResponse>() ?: return "$episodeId\$sub" to "Subbed",
"$episodeId\$dub" to "English Dub",
).apmap { (id, type) ->
val sources = app.get("$consumetZoroAPI/watch?episodeId=$id")
.parsedSafe<ConsumetSourcesResponse>() ?: return@apmap null
sources.sources?.map { sources.sources?.map sources@{
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
"Zoro", "Zoro [$type]",
"Zoro", "Zoro [$type]",
it.url ?: return@map null, it.url ?: return@sources null,
"", "",
getQualityFromName(it.quality), getQualityFromName(it.quality),
it.isM3U8 ?: true it.isM3U8 ?: true
)
) )
) }
}
sources.subtitles?.map { sources.subtitles?.map subtitles@{
subtitleCallback.invoke( subtitleCallback.invoke(
SubtitleFile( SubtitleFile(
it.lang ?: "", it.lang ?: "",
it.url ?: return@map null it.url ?: return@subtitles null
)
) )
) }
} }
@ -1476,30 +1481,36 @@ object SoraExtractor : SoraStream() {
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.number == episode || it.title.equals(epsTitle, true)) && it.type == "Subbed" (it.number == episode || it.title.equals(epsTitle, true))
}?.map { it.id }?.getOrNull(season?.minus(1) ?: 0) ?: return }?.let { eps ->
listOf(eps.filter { it.type == "Subbed" }.map { it.id }
val json = app.get("$consumetCrunchyrollAPI/watch?episodeId=$episodeId&format=srt") .getOrNull(season?.minus(1) ?: 0) to "Subbed",
.parsedSafe<ConsumetSourcesResponse>() eps.filter { it.type == "English Dub" }.map { it.id }
.getOrNull(season?.minus(1) ?: 0) to "English Dub")
json?.sources?.map source@{ source ->
M3u8Helper.generateM3u8(
"Crunchyroll",
source.url ?: return@source null,
"",
).forEach(callback)
} }
json?.subtitles?.map subtitle@{ sub -> episodeId?.apmap { (id, type) ->
subtitleCallback.invoke( val json = app.get("$consumetCrunchyrollAPI/watch?episodeId=${id ?: return@apmap null}&format=srt")
SubtitleFile( .parsedSafe<ConsumetSourcesResponse>()
sub.lang?.replace(Regex("\\[\\S+]"), "")?.trim() ?: "",
sub.url ?: return@subtitle null json?.sources?.map source@{ source ->
M3u8Helper.generateM3u8(
"Crunchyroll [$type]",
source.url ?: return@source null,
"",
).forEach(callback)
}
json?.subtitles?.map subtitle@{ sub ->
subtitleCallback.invoke(
SubtitleFile(
sub.lang?.replace(Regex("\\[\\S+]"), "")?.trim() ?: "",
sub.url ?: return@subtitle null
)
) )
) }
} }
} }
} }

View file

@ -208,12 +208,11 @@ open class SoraStream : TmdbProvider() {
?.randomOrNull() ?.randomOrNull()
return if (type == TvType.TvSeries) { return if (type == TvType.TvSeries) {
val episodes = mutableListOf<Episode>()
val lastSeason = res.seasons?.lastOrNull()?.seasonNumber val lastSeason = res.seasons?.lastOrNull()?.seasonNumber
res.seasons?.apmap { season -> val episodes = res.seasons?.mapNotNull { season ->
app.get("$tmdbAPI/${data.type}/${data.id}/season/${season.seasonNumber}?api_key=$apiKey") app.get("$tmdbAPI/${data.type}/${data.id}/season/${season.seasonNumber}?api_key=$apiKey")
.parsedSafe<MediaDetailEpisodes>()?.episodes?.map { eps -> .parsedSafe<MediaDetailEpisodes>()?.episodes?.map { eps ->
episodes.add(Episode( Episode(
LinkData( LinkData(
data.id, data.id,
res.external_ids?.imdb_id, res.external_ids?.imdb_id,
@ -236,9 +235,9 @@ open class SoraStream : TmdbProvider() {
description = eps.overview description = eps.overview
).apply { ).apply {
this.addDate(eps.airDate) this.addDate(eps.airDate)
}) }
} }
} }?.flatten() ?: listOf()
newTvSeriesLoadResponse( newTvSeriesLoadResponse(
title, title,
url, url,

View file

@ -1,6 +1,5 @@
import com.lagradost.cloudstream3.gradle.CloudstreamExtension import com.lagradost.cloudstream3.gradle.CloudstreamExtension
import com.android.build.gradle.BaseExtension import com.android.build.gradle.BaseExtension
import java.util.Properties
buildscript { buildscript {
repositories { repositories {
@ -43,11 +42,11 @@ subprojects {
} }
android { android {
compileSdkVersion(32) compileSdkVersion(33)
defaultConfig { defaultConfig {
minSdk = 21 minSdk = 21
targetSdk = 32 targetSdk = 33
// val properties = Properties() // val properties = Properties()
// properties.load(project.rootProject.file("local.properties").inputStream()) // properties.load(project.rootProject.file("local.properties").inputStream())
@ -84,8 +83,8 @@ subprojects {
// but you dont need to include any of them if you dont need them // but you dont need to include any of them if you dont need them
// https://github.com/recloudstream/cloudstream/blob/master/app/build.gradle // https://github.com/recloudstream/cloudstream/blob/master/app/build.gradle
implementation(kotlin("stdlib")) // adds standard kotlin features, like listOf, mapOf etc implementation(kotlin("stdlib")) // adds standard kotlin features, like listOf, mapOf etc
implementation("com.github.Blatzar:NiceHttp:0.3.5") // http library implementation("com.github.Blatzar:NiceHttp:0.4.1") // http library
implementation("org.jsoup:jsoup:1.13.1") // html parser implementation("org.jsoup:jsoup:1.15.3") // html parser
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.1") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.1")
implementation("io.karn:khttp-android:0.1.2") implementation("io.karn:khttp-android:0.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4") // html parser implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4") // html parser