feat(en/seez): Add status, next episode air date and languages (#2833)

This commit is contained in:
Samfun75 2024-01-29 15:48:57 +03:00 committed by GitHub
parent 2db2733489
commit 4470991ee4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 99 additions and 36 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Seez'
extClass = '.Seez'
extVersionCode = 7
extVersionCode = 8
}
apply from: "$rootDir/common.gradle"

View File

@ -30,6 +30,7 @@ import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
import java.net.URLDecoder
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec
@ -89,11 +90,11 @@ class Seez : ConfigurableAnimeSource, AnimeHttpSource() {
SAnime.create().apply {
title = name
url = LinkData(ani.id, "movie").toJsonString()
thumbnail_url = ani.poster_path?.let { IMG_URL + it } ?: FALLBACK_IMG
thumbnail_url = ani.posterPath?.let { IMG_URL + it } ?: FALLBACK_IMG
}
}
return AnimesPage(animeList, data.page < data.total_pages)
return AnimesPage(animeList, data.page < data.totalPages)
}
// =============================== Latest ===============================
@ -140,12 +141,13 @@ class Seez : ConfigurableAnimeSource, AnimeHttpSource() {
SAnime.create().apply {
title = name
url = LinkData(ani.id, ani.media_type).toJsonString()
thumbnail_url = ani.poster_path?.let { IMG_URL + it } ?: FALLBACK_IMG
url = LinkData(ani.id, ani.mediaType).toJsonString()
thumbnail_url = ani.posterPath?.let { IMG_URL + it } ?: FALLBACK_IMG
status = if (ani.mediaType == "movie") SAnime.COMPLETED else SAnime.UNKNOWN
}
}
return AnimesPage(animeList, data.page < data.total_pages)
return AnimesPage(animeList, data.page < data.totalPages)
}
// ============================== Filters ===============================
@ -197,9 +199,8 @@ class Seez : ConfigurableAnimeSource, AnimeHttpSource() {
val data = json.decodeFromString<LinkData>(anime.url)
val url = TMDB_URL.newBuilder().apply {
addPathSegment(data.media_type)
addPathSegment(data.mediaType)
addPathSegment(data.id.toString())
addQueryParameter("append_to_response", "videos,credits,recommendations")
}.buildAPIUrl()
return GET(url, headers = apiHeaders)
@ -209,15 +210,34 @@ class Seez : ConfigurableAnimeSource, AnimeHttpSource() {
val data = response.parseAs<TmdbDetailsResponse>()
return SAnime.create().apply {
genre = data.genres?.joinToString(", ") { it.name }
description = buildString {
if (data.overview != null) {
append(data.overview)
append("\n\n")
author = data.productions?.joinToString { it.name }
genre = data.genres?.joinToString { it.name }
status = when (data.status) {
"Ended", "Released" -> SAnime.COMPLETED
"In Production" -> SAnime.LICENSED
"Canceled" -> SAnime.CANCELLED
"Returning Series" -> {
data.nextEpisode?.let { SAnime.ONGOING } ?: SAnime.ON_HIATUS
}
else -> SAnime.UNKNOWN
}
description = buildString {
data.overview?.let {
appendLine(it)
appendLine()
}
data.nextEpisode?.let {
appendLine("Next: Ep ${it.epNumber} - ${it.name}")
appendLine("Air Date: ${it.airDate}")
appendLine()
}
data.releaseDate?.let { appendLine("Release date: $it") }
data.firstAirDate?.let { appendLine("First air date: $it") }
data.lastAirDate?.let { appendLine("Last air date: $it") }
data.languages?.let { langs ->
append("Languages: ")
appendLine(langs.joinToString { "${it.engName} (${it.name})" })
}
if (data.release_date != null) append("Release date: ${data.release_date}")
if (data.first_air_date != null) append("\nFirst air date: ${data.first_air_date}")
if (data.last_air_date != null) append("\nLast air date: ${data.last_air_date}")
}
}
}
@ -234,31 +254,35 @@ class Seez : ConfigurableAnimeSource, AnimeHttpSource() {
episodeList.add(
SEpisode.create().apply {
name = "Movie"
date_upload = parseDate(data.release_date!!)
date_upload = parseDate(data.releaseDate!!)
episode_number = 1F
url = "/movie/${data.id}"
},
)
} else {
data.seasons.filter { t -> t.season_number != 0 }.forEach { season ->
data.seasons.filter { t -> t.seasonNumber != 0 }.forEach { season ->
val seasonUrl = TMDB_URL.newBuilder().apply {
addPathSegment("tv")
addPathSegment(data.id.toString())
addPathSegment("season")
addPathSegment(season.season_number.toString())
addPathSegment(season.seasonNumber.toString())
}.buildAPIUrl()
val seasonData = client.newCall(
GET(seasonUrl, headers = apiHeaders),
).execute().parseAs<TmdbSeasonResponse>()
seasonData.episodes.forEach { ep ->
seasonData.episodes.filter { ep ->
ep.airDate?.let {
DATE_FORMATTER.parse(it)!! <= DATE_FORMATTER.parse(DATE_FORMATTER.format(Date()))
} ?: false
}.forEach { ep ->
episodeList.add(
SEpisode.create().apply {
name = "Season ${season.season_number} Ep. ${ep.episode_number} - ${ep.name}"
date_upload = ep.air_date?.let(::parseDate) ?: 0L
episode_number = ep.episode_number.toFloat()
url = "/tv/${data.id}/${season.season_number}/${ep.episode_number}"
name = "Season ${season.seasonNumber} Ep. ${ep.epNumber} - ${ep.name}"
date_upload = ep.airDate?.let(::parseDate) ?: 0L
episode_number = ep.epNumber.toFloat()
url = "/tv/${data.id}/${season.seasonNumber}/${ep.epNumber}"
},
)
}

View File

@ -1,18 +1,22 @@
package eu.kanade.tachiyomi.animeextension.en.seez
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class TmdbResponse(
val page: Int,
val total_pages: Int,
@SerialName("total_pages")
val totalPages: Int,
val results: List<TmdbResult>,
) {
@Serializable
data class TmdbResult(
val id: Int,
val media_type: String = "tv",
val poster_path: String? = null,
@SerialName("media_type")
val mediaType: String = "tv",
@SerialName("poster_path")
val posterPath: String? = null,
val title: String? = null,
val name: String? = null,
)
@ -23,12 +27,22 @@ data class TmdbDetailsResponse(
val id: Int,
val overview: String? = null,
val genres: List<GenreObject>? = null,
val release_date: String? = null,
val first_air_date: String? = null,
val last_air_date: String? = null,
@SerialName("release_date")
val releaseDate: String? = null,
@SerialName("first_air_date")
val firstAirDate: String? = null,
@SerialName("last_air_date")
val lastAirDate: String? = null,
val name: String? = null,
val title: String? = null,
val seasons: List<SeasonObject> = emptyList(),
val status: String,
@SerialName("next_episode_to_air")
val nextEpisode: NextEpisode? = null,
@SerialName("production_companies")
val productions: List<Company>? = null,
@SerialName("spoken_languages")
val languages: List<Language>? = null,
) {
@Serializable
data class GenreObject(
@ -37,9 +51,31 @@ data class TmdbDetailsResponse(
@Serializable
data class SeasonObject(
val season_number: Int,
// id 787
// name "Book Two: Earth"
@SerialName("season_number")
val seasonNumber: Int,
)
@Serializable
data class NextEpisode(
val name: String? = "",
@SerialName("episode_number")
val epNumber: Int,
@SerialName("air_date")
val airDate: String,
)
@Serializable
data class Company(
val name: String,
@SerialName("origin_country")
val originCountry: String,
)
@Serializable
data class Language(
val name: String,
@SerialName("english_name")
val engName: String,
)
}
@ -49,16 +85,19 @@ data class TmdbSeasonResponse(
) {
@Serializable
data class EpisodeObject(
val episode_number: Int,
@SerialName("episode_number")
val epNumber: Int,
val name: String,
val air_date: String? = null,
@SerialName("air_date")
val airDate: String? = null,
)
}
@Serializable
data class LinkData(
val id: Int,
val media_type: String,
@SerialName("media_type")
val mediaType: String,
)
@Serializable