Consumyroll: apply fixes for stable and fix anime with no versions (#1262)

This commit is contained in:
Samfun75
2023-02-10 11:22:10 +03:00
committed by GitHub
parent f6850d0e8b
commit 053c012a20
3 changed files with 24 additions and 11 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Consumyroll'
pkgNameSuffix = 'all.kamyroll'
extClass = '.Consumyroll'
extVersionCode = 12
extVersionCode = 13
libVersion = '13'
}

View File

@ -110,7 +110,15 @@ class Consumyroll : ConfigurableAnimeSource, AnimeHttpSource() {
val mediaId = json.decodeFromString<LinkData>(anime.url)
val resp = client.newCall(GET("$crUrl/content/v2/cms/series/${mediaId.id}?locale=en-US")).execute()
val info = json.decodeFromString<AnimeResult>(resp.body!!.string())
return Observable.just(anime.apply { author = info.data.first().content_provider })
return Observable.just(
anime.apply {
author = info.data.first().content_provider
status = SAnime.COMPLETED
if (genre.isNullOrBlank()) {
genre = info.data.first().genres?.joinToString { gen -> gen.replaceFirstChar { it.uppercase() } }
}
}
)
}
override fun animeDetailsParse(response: Response): SAnime = throw Exception("not used")
@ -131,9 +139,12 @@ class Consumyroll : ConfigurableAnimeSource, AnimeHttpSource() {
episodes.data.sortedBy { it.episode_number }.map { ep ->
SEpisode.create().apply {
url = EpisodeData(
ep.versions?.map { Pair(it.mediaId, it.audio_locale) } ?: listOf(Pair(ep.id, ep.audio_locale))
ep.versions?.map { Pair(it.mediaId, it.audio_locale) } ?: listOf(Pair(
ep.streams_link.substringAfter("videos/").substringBefore("/streams"),
ep.audio_locale
))
).toJsonString()
name = if (ep.episode_number > 0 || ep.episode.isNumeric()) {
name = if (ep.episode_number > 0 && ep.episode.isNumeric()) {
"Season ${seasonData.season_number} Ep ${df.format(ep.episode_number)}: " + ep.title
} else { ep.title }
episode_number = ep.episode_number
@ -224,8 +235,8 @@ class Consumyroll : ConfigurableAnimeSource, AnimeHttpSource() {
return locale.firstOrNull { it.first == this }?.second ?: ""
}
private fun String.isNumeric(): Boolean {
return this@isNumeric.toDoubleOrNull() != null
private fun String?.isNumeric(): Boolean {
return this@isNumeric?.toDoubleOrNull() != null
}
private val locale = arrayOf(
@ -281,7 +292,7 @@ class Consumyroll : ConfigurableAnimeSource, AnimeHttpSource() {
desc += if (this@toSAnime.series_metadata.is_simulcast) "\nSimulcast" else ""
desc += "\n\nAudio: " + this@toSAnime.series_metadata.audio_locales.joinToString { it.getLocale() }
desc += "\n\nSubs: " + this@toSAnime.series_metadata.subtitle_locales.joinToString { it.getLocale() }
description += desc
description = desc
}
override fun List<Video>.sort(): List<Video> {

View File

@ -40,6 +40,8 @@ data class Anime(
val title: String,
val description: String,
val images: Images,
@SerialName("keywords")
val genres: ArrayList<String>? = null,
val series_metadata: Metadata? = null,
val content_provider: String? = null,
val audio_locales: ArrayList<String>? = null,
@ -52,7 +54,7 @@ data class Anime(
val audio_locales: ArrayList<String>,
val subtitle_locales: ArrayList<String>,
@SerialName("tenant_categories")
val genres: ArrayList<String>?
val genres: ArrayList<String>? = null
)
}
@ -92,15 +94,15 @@ data class EpisodeResult(
) {
@Serializable
data class Episode(
val id: String,
val audio_locale: String,
val title: String,
@SerialName("sequence_number")
val episode_number: Float,
val episode: String,
val episode: String? = null,
@SerialName("episode_air_date")
val airDate: String? = null,
val versions: ArrayList<Version>? = null
val versions: ArrayList<Version>? = null,
val streams_link: String
) {
@Serializable
data class Version(