fix missing anime in Crunchyroll

This commit is contained in:
hexated 2023-01-19 17:23:58 +07:00
parent 0f0f680047
commit 4905e8f868
3 changed files with 13 additions and 7 deletions

View File

@ -1665,17 +1665,17 @@ object SoraExtractor : SoraStream() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
val res = app.get("$consumetCrunchyrollAPI/$title") val res = (searchCrunchyroll(title)
.parsedSafe<ConsumetSearchResponse>()?.results ?: return ?: searchCrunchyroll(title?.substringBefore(" ")))?.results
val id = (if (res.size == 1) { val id = (if (res?.size == 1) {
res.firstOrNull() res.firstOrNull()
} else { } else {
res.find { res?.find {
it.title.equals( (it.title.equals(
title, title,
true true
) && it.type.equals("series") ) || it.title.fixTitle().equals(title.fixTitle(), true)) && it.type.equals("series")
} }
})?.id ?: return })?.id ?: return

View File

@ -207,7 +207,7 @@ open class SoraStream : TmdbProvider() {
val year = (res.releaseDate ?: res.firstAirDate)?.split("-")?.first()?.toIntOrNull() val year = (res.releaseDate ?: res.firstAirDate)?.split("-")?.first()?.toIntOrNull()
val rating = res.vote_average.toString().toRatingInt() val rating = res.vote_average.toString().toRatingInt()
val genres = res.genres?.mapNotNull { it.name } val genres = res.genres?.mapNotNull { it.name }
val isAnime = genres?.contains("Animation") == true && res.original_language == "ja" val isAnime = genres?.contains("Animation") == true && (res.original_language == "zh" || res.original_language == "ja")
val keywords = res.keywords?.results?.mapNotNull { it.name }.orEmpty() val keywords = res.keywords?.results?.mapNotNull { it.name }.orEmpty()
.ifEmpty { res.keywords?.keywords?.mapNotNull { it.name } } .ifEmpty { res.keywords?.keywords?.mapNotNull { it.name } }

View File

@ -1,5 +1,6 @@
package com.hexated package com.hexated
import com.hexated.SoraStream.Companion.consumetCrunchyrollAPI
import com.hexated.SoraStream.Companion.filmxyAPI import com.hexated.SoraStream.Companion.filmxyAPI
import com.hexated.SoraStream.Companion.gdbot import com.hexated.SoraStream.Companion.gdbot
import com.hexated.SoraStream.Companion.tvMoviesAPI import com.hexated.SoraStream.Companion.tvMoviesAPI
@ -468,6 +469,11 @@ fun Document.findTvMoviesIframe(): String? {
?.substringBefore("'>") ?.substringBefore("'>")
} }
suspend fun searchCrunchyroll(title: String?) : ConsumetSearchResponse? {
return app.get("${consumetCrunchyrollAPI}/$title")
.parsedSafe()
}
fun CrunchyrollDetails.findCrunchyrollId( fun CrunchyrollDetails.findCrunchyrollId(
title: String?, title: String?,
season: Int?, season: Int?,