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,
callback: (ExtractorLink) -> Unit
) {
val id = getCrunchyrollId(aniId) ?: return
val id = getCrunchyrollId(aniId)
val audioLocal = listOf(
"ja-JP",
"en-US",
"zh-CN",
)
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 ->
if (s.size == 1) {
s.firstOrNull()
@ -1496,9 +1496,9 @@ object SoraExtractor : SoraStream() {
}
}
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 =
app.get(
"$crunchyrollAPI/content/v2/cms/seasons/${sId ?: return@apmap}/episodes",

View File

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