sora: small fix in crunchy

This commit is contained in:
hexated 2023-05-21 23:49:00 +07:00
parent 52d49fdaec
commit aa25976a1b
2 changed files with 10 additions and 8 deletions

View file

@ -1474,14 +1474,14 @@ object SoraExtractor : SoraStream() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
val id = getCrunchyrollId(aniId) ?: return val id = getCrunchyrollId(aniId)
val audioLocal = listOf( val audioLocal = listOf(
"ja-JP", "ja-JP",
"en-US", "en-US",
"zh-CN", "zh-CN",
) )
val headers = getCrunchyrollToken() val headers = getCrunchyrollToken()
val seasonIdData = app.get("$crunchyrollAPI/content/v2/cms/series/$id/seasons", headers = headers) val seasonIdData = app.get("$crunchyrollAPI/content/v2/cms/series/${id ?: return}/seasons", headers = headers)
.parsedSafe<CrunchyrollResponses>()?.data?.let { s -> .parsedSafe<CrunchyrollResponses>()?.data?.let { s ->
if (s.size == 1) { if (s.size == 1) {
s.firstOrNull() s.firstOrNull()
@ -1496,9 +1496,9 @@ object SoraExtractor : SoraStream() {
} }
} }
val seasonId = seasonIdData?.versions?.filter { it.audio_locale in audioLocal } val seasonId = seasonIdData?.versions?.filter { it.audio_locale in audioLocal }
?.map { it.guid to it.audio_locale } ?.map { it.guid to it.audio_locale } ?: listOf(seasonIdData?.id to "ja-JP")
seasonId?.apmap { (sId, audioL) -> seasonId.apmap { (sId, audioL) ->
val streamsLink = val streamsLink =
app.get( app.get(
"$crunchyrollAPI/content/v2/cms/seasons/${sId ?: return@apmap}/episodes", "$crunchyrollAPI/content/v2/cms/seasons/${sId ?: return@apmap}/episodes",

View file

@ -957,10 +957,12 @@ suspend fun getCrunchyrollId(aniId: String?): String? {
"variables" to variables "variables" to variables
).toJson().toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull()) ).toJson().toRequestBody(RequestBodyTypes.JSON.toMediaTypeOrNull())
return app.post("https://graphql.anilist.co", requestBody = data) val externalLinks = app.post("https://graphql.anilist.co", requestBody = data)
.parsedSafe<AnilistResponses>()?.data?.Media?.externalLinks?.find { it.site == "VRV" }?.url?.let { .parsedSafe<AnilistResponses>()?.data?.Media?.externalLinks
Regex("series/(\\w+)/?").find(it)?.groupValues?.get(1)
} return (externalLinks?.find { it.site == "VRV" } ?: externalLinks?.find { it.site == "Crunchyroll" })?.url?.let {
Regex("series/(\\w+)/?").find(it)?.groupValues?.get(1)
}
} }
suspend fun extractPutlockerSources(url: String?): NiceResponse? { suspend fun extractPutlockerSources(url: String?): NiceResponse? {