diff --git a/src/main/kotlin/com/jeluchu/core/models/jikan/anime/Episodes.kt b/src/main/kotlin/com/jeluchu/core/models/jikan/anime/Episodes.kt new file mode 100644 index 0000000..27592d2 --- /dev/null +++ b/src/main/kotlin/com/jeluchu/core/models/jikan/anime/Episodes.kt @@ -0,0 +1,27 @@ +package com.jeluchu.core.models.jikan.anime + +import com.jeluchu.core.models.jikan.search.Pagination +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class Episodes( + + @SerialName("mal_id") + val malId: Int? = 0, + + @SerialName("title") + val title: String? = "", + + @SerialName("episode") + val episode: String? = "", + + @SerialName("url") + val url: String? = "", + + /** + * Data list of all anime found. + */ + @SerialName("data") + val data: List? = emptyList() +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/core/utils/Constants.kt b/src/main/kotlin/com/jeluchu/core/utils/Constants.kt index fc7d534..78e7409 100644 --- a/src/main/kotlin/com/jeluchu/core/utils/Constants.kt +++ b/src/main/kotlin/com/jeluchu/core/utils/Constants.kt @@ -39,6 +39,7 @@ object RssSources { object Endpoints { const val POSTS = "posts" const val ANIME = "anime" + const val EPISODES = "episodes" const val SCHEDULES = "schedules" const val TOP_ANIME = "top/anime" const val TOP_MANGA = "top/manga" @@ -63,6 +64,7 @@ object Routes { const val ANITAKUME = "/anitakume" const val CHARACTER = "/characters" const val LAST_EPISODES = "/lastEpisodes" + const val EPISODES = "/episodes" const val ID = "/{id}" const val TYPE = "/{type}" const val SEASON = "/{year}/{season}" @@ -76,6 +78,7 @@ object TimerKey { const val LAST_UPDATED = "lastUpdated" const val ANIME_TYPE = "anime_" const val THEMES = "themes_" + const val EPISODES = "episodes_" const val LAST_EPISODES = "last_episodes" } @@ -87,11 +90,11 @@ object Collections { const val ANITAKUME = "anitakume" const val ANIME_THEMES = "anime_themes" const val ARTISTS_INDEX = "artists_index" - const val ANIME_DETAILS = "anime_details" const val LAST_EPISODES = "last_episodes" const val ANIME_RANKING = "anime_ranking" const val MANGA_RANKING = "manga_ranking" const val PEOPLE_RANKING = "people_ranking" + const val ANIME_DIRECTORY = "anime_directory" const val CHARACTER_RANKING = "character_ranking" const val ANIME_PICTURES_QUERY = "anime_pictures_query" const val ANIME_PICTURES_RECENT = "anime_pictures_recent" diff --git a/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt b/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt index 30a28ff..939e7b4 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt @@ -1,96 +1,104 @@ package com.jeluchu.features.anime.mappers -import com.jeluchu.features.themes.models.anime.AnimeThemeEntry import com.jeluchu.core.extensions.* import com.jeluchu.features.anime.models.anime.* import com.jeluchu.features.anime.models.directory.AnimeTypeEntity -import com.jeluchu.features.anime.models.lastepisodes.LastEpisodeData +import com.jeluchu.features.anime.models.lastepisodes.LastEpisodeEntity import com.jeluchu.features.rankings.models.AnimeTopEntity import com.jeluchu.features.rankings.models.CharacterTopEntity import com.jeluchu.features.rankings.models.MangaTopEntity import com.jeluchu.features.rankings.models.PeopleTopEntity import com.jeluchu.features.schedule.models.DayEntity -import com.jeluchu.features.themes.models.anime.Anime -import com.jeluchu.features.themes.models.anime.AnimeVideoTheme -import com.jeluchu.features.themes.models.anime.AnimesEntity -import com.jeluchu.features.themes.models.anime.Video +import com.jeluchu.features.themes.models.anime.* import org.bson.Document -import java.time.ZonedDateTime -import java.time.format.DateTimeFormatter fun documentToMoreInfoEntity(doc: Document): MoreInfoEntity { return MoreInfoEntity( id = doc.getObjectId("_id").toString(), malId = doc.getIntSafe("malId"), + rank = doc.getIntSafe("rank"), title = doc.getStringSafe("title"), + episodes = doc.getIntSafe("episodes"), + episodeList = doc.getListSafe("episodeList").map { documentToEpisodeInfo(it) }, + type = doc.getStringSafe("type"), + status = doc.getStringSafe("status"), + season = doc.getDocumentSafe("season")?.let { documentToSeasonalEntity(it) }, poster = doc.getStringSafe("poster"), cover = doc.getStringSafe("cover"), - genres = doc.getListSafe("genres"), - synopsis = doc.getStringSafe("synopsis"), - episodes = doc.getListSafe("episodes").map { documentToMergedEpisode(it) }, - episodesCount = doc.getIntSafe("episodesCount", 0), + duration = doc.getDocumentSafe("duration")?.let { documentToEpisodeDurationEntity(it) }, score = doc.getStringSafe("score"), - staff = doc.getListSafe("staff").map { documentToStaff(it) }, - characters = doc.getListSafe("characters").map { documentToCharacter(it) }, - status = doc.getStringSafe("status"), - type = doc.getStringSafe("type"), - url = doc.getStringSafe("url"), - promo = doc.getDocumentSafe("promo")?.let { documentToVideoPromo(it) }, - duration = doc.getStringSafe("duration"), - rank = doc.getIntSafe("rank", 0), - titles = doc.getListSafe("titles").map { documentToAlternativeTitles(it) }, - airing = doc.getBooleanSafe("airing"), - aired = doc.getDocumentSafe("aired")?.let { documentToAiringTime(it) } ?: AiringTime(), - broadcast = doc.getDocumentSafe("broadcast")?.let { documentToAnimeBroadcast(it) } ?: AnimeBroadcast(), - season = doc.getStringSafe("season"), - year = doc.getIntSafe("year", 0), - external = doc.getListSafe("external").map { documentToExternalLinks(it) }, - streaming = doc.getListSafe("streaming").map { documentToExternalLinks(it) }, + titles = doc.getDocumentSafe("titles")?.let { documentToOtherTitlesEntity(it) }, studios = doc.getListSafe("studios").map { documentToCompanies(it) }, - licensors = doc.getListSafe("licensors").map { documentToCompanies(it) }, producers = doc.getListSafe("producers").map { documentToCompanies(it) }, - theme = doc.getDocumentSafe("theme")?.let { documentToThemes(it) } ?: Themes(), + licensors = doc.getListSafe("licensors").map { documentToCompanies(it) }, relations = doc.getListSafe("relations").map { documentToRelated(it) }, - stats = doc.getDocumentSafe("stats")?.let { documentToStatistics(it) } ?: Statistics(), - gallery = doc.getListSafe("gallery").map { documentToImageMediaEntity(it) }, - episodeSource = doc.getStringSafe("episodeSource") + promo = doc.getDocumentSafe("promo")?.let { documentToVideoPromo(it) }, + tags = doc.getDocumentSafe("genres")?.let { documentToMultipleLanguageLists(it) }, + synopsis = doc.getDocumentSafe("synopsis")?.let { documentToMultipleLanguage(it) }, + staff = doc.getListSafe("staff").map { documentToStaff(it) }, + characters = doc.getListSafe("characters").map { documentToCharacter(it) }, + streaming = doc.getListSafe("streaming").map { documentToExternalLinks(it) }, + urls = doc.getListSafe("urls").takeIf { it.isNotEmpty() } ?: listOf(doc.getStringSafe("url")).filter { it.isNotEmpty() }, + broadcast = doc.getDocumentSafe("broadcast")?.let { documentToAnimeBroadcast(it) }, + external = doc.getListSafe("external").map { documentToExternalLinks(it) }, + stats = doc.getDocumentSafe("stats")?.let { documentToStatistics(it) }, + nsfw = doc.getBooleanSafe("nsfw", false), + ageRating = doc.getStringSafe("ageRating"), + aired = doc.getDocumentSafe("aired")?.let { documentToAiringTime(it) }, + themes = doc.getDocumentSafe("theme")?.let { documentToThemes(it) } ) } -fun documentToActor(doc: Document): Actor { - return Actor( - person = doc.getDocumentSafe("person")?.let { documentToIndividual(it) } ?: Individual(), - language = doc.getStringSafe("language") +fun documentToEpisodeInfo(doc: Document): EpisodeInfo { + return EpisodeInfo( + number = doc.getIntSafe("number"), + seasonNumber = doc.getIntSafe("season_number"), + relativeNumber = doc.getIntSafe("relative_number"), + airdate = doc.getStringSafe("airdate"), + duration = doc.getIntSafe("duration"), + thumbnail = doc.getStringSafe("thumbnail"), + synopsis = doc.getDocumentSafe("synopsis")?.let { documentToMultipleLanguage(it) }, + titles = doc.getDocumentSafe("titles")?.let { documentToMultipleLanguageTitles(it) }, + score = doc.getDoubleSafe("score"), + filler = doc.getBooleanSafe("filler", false), + recap = doc.getBooleanSafe("recap", false) ) } -fun documentToAiringTime(doc: Document): AiringTime { - return AiringTime( - from = doc.getStringSafe("from"), - to = doc.getStringSafe("to") +fun documentToMultipleLanguage(doc: Document): MultipleLanguage { + return MultipleLanguage( + es = doc.getStringSafe("es"), + en = doc.getStringSafe("en") ) } -fun documentToAlternativeTitles(doc: Document): AlternativeTitles { - return AlternativeTitles( - title = doc.getStringSafe("title"), - type = doc.getStringSafe("type") +fun documentToMultipleLanguageTitles(doc: Document): MultipleLanguageTitles { + return MultipleLanguageTitles( + es = doc.getStringSafe("es"), + en = doc.getStringSafe("en"), + jp = doc.getStringSafe("jp"), + romaji_jp = doc.getStringSafe("romaji_jp") ) } -fun documentToAnimeBroadcast(doc: Document): AnimeBroadcast { - return AnimeBroadcast( - day = doc.getStringSafe("day"), - time = doc.getStringSafe("time"), - timezone = doc.getStringSafe("timezone") +fun documentToSeasonalEntity(doc: Document): SeasonalEntity { + return SeasonalEntity( + station = doc.getStringSafe("station"), + year = doc.getIntSafe("year") ) } -fun documentToCharacter(doc: Document): Character { - return Character( - character = doc.getDocumentSafe("character")?.let { documentToIndividual(it) } ?: Individual(), - role = doc.getStringSafe("role"), - voiceActor = doc.getListSafe("voiceActor").map { documentToActor(it) } +fun documentToEpisodeDurationEntity(doc: Document): EpisodeDurationEntity { + return EpisodeDurationEntity( + unit = doc.getStringSafe("unit"), + value = doc.getIntSafe("value") + ) +} + +fun documentToOtherTitlesEntity(doc: Document): OtherTitlesEntity { + return OtherTitlesEntity( + synonyms = doc.getListSafe("synonyms"), + abbreviatedTitles = doc.getListSafe("abbreviated_titles") ) } @@ -103,20 +111,19 @@ fun documentToCompanies(doc: Document): Companies { ) } -fun documentToExternalLinks(doc: Document): ExternalLinks { - return ExternalLinks( - url = doc.getStringSafe("url"), - name = doc.getStringSafe("name") +fun documentToRelated(doc: Document): Related { + return Related( + entry = doc.getListSafe("entry").map { documentToCompanies(it) }, + relation = doc.getStringSafe("relation") ) } -fun documentToImageMediaEntity(doc: Document): ImageMediaEntity { - return ImageMediaEntity( - media = doc.getStringSafe("media"), - thumbnail = doc.getStringSafe("thumbnail"), - width = doc.getIntSafe("width", 0), - height = doc.getIntSafe("height", 0), - url = doc.getStringSafe("url") +fun documentToVideoPromo(doc: Document): VideoPromo { + return VideoPromo( + embedUrl = doc.getStringSafe("embedUrl"), + url = doc.getStringSafe("url"), + youtubeId = doc.getStringSafe("youtubeId"), + images = doc.getDocumentSafe("images")?.let { documentToImages(it) } ?: Images() ) } @@ -130,51 +137,51 @@ fun documentToImages(doc: Document): Images { ) } -fun documentToIndividual(doc: Document): Individual { - return Individual( - malId = doc.getIntSafe("malId", 0), - url = doc.getStringSafe("url"), - name = doc.getStringSafe("name"), - images = doc.getStringSafe("images") +fun documentToMultipleLanguageLists(doc: Document): MultipleLanguageLists { + return MultipleLanguageLists( + es = doc.getListSafe("es"), + en = doc.getListSafe("en") ) } -fun documentToMergedEpisode(doc: Document): MergedEpisode { - return MergedEpisode( - malId = doc.getIntSafe("malId"), - title = doc.getStringSafe("title"), - titleJapanese = doc.getStringSafe("titleJapanese"), - titleRomanji = doc.getStringSafe("titleRomanji"), - aired = doc.getStringSafe("aired", ZonedDateTime.now().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)), - score = doc.getFloatSafe("score"), - filler = doc.getBooleanSafe("filler"), - recap = doc.getBooleanSafe("recap") +fun documentToStaff(doc: Document): Staff { + return Staff( + person = doc.getDocumentSafe("person")?.let { documentToIndividual(it) } ?: Individual(), + positions = doc.getListSafe("positions") ) } -fun documentToRelated(doc: Document): Related { - return Related( - entry = doc.getListSafe("entry").map { documentToCompanies(it) }, - relation = doc.getStringSafe("relation") +fun documentToCharacter(doc: Document): Character { + return Character( + malId = doc.getIntSafe("mal_id", 0), + url = doc.getStringSafe("url"), + name = doc.getStringSafe("name"), + images = doc.getStringSafe("images"), + role = doc.getStringSafe("role"), + voiceActor = doc.getListSafe("voice_actor").map { documentToActor(it) } ) } -fun documentToScore(doc: Document): Score { - return Score( - percentage = when (val value = doc["percentage"]) { - is Double -> value - is Int -> value.toDouble() - else -> 0.0 - }, - score = doc.getIntSafe("score", 0), - votes = doc.getIntSafe("votes", 0) +fun documentToActor(doc: Document): Actor { + return Actor( + person = doc.getDocumentSafe("person")?.let { documentToIndividual(it) } ?: Individual(), + language = doc.getStringSafe("language") ) } -fun documentToStaff(doc: Document): Staff { - return Staff( - person = doc.get("person", Document::class.java)?.let { documentToIndividual(it) } ?: Individual(), - positions = doc.getListSafe("positions") +fun documentToIndividual(doc: Document): Individual { + return Individual( + malId = doc.getIntSafe("malId", 0), + url = doc.getStringSafe("url"), + name = doc.getStringSafe("name"), + images = doc.getStringSafe("images") + ) +} + +fun documentToExternalLinks(doc: Document): ExternalLinks { + return ExternalLinks( + url = doc.getStringSafe("url"), + name = doc.getStringSafe("name") ) } @@ -190,19 +197,37 @@ fun documentToStatistics(doc: Document): Statistics { ) } +fun documentToAiringTime(doc: Document): AiringTime { + return AiringTime( + from = doc.getStringSafe("from"), + to = doc.getStringSafe("to") + ) +} + fun documentToThemes(doc: Document): Themes { return Themes( - endings = doc.getListSafe("endings"), - openings = doc.getListSafe("openings") + openings = doc.getListSafe("openings"), + endings = doc.getListSafe("endings") ) } -fun documentToVideoPromo(doc: Document): VideoPromo { - return VideoPromo( - embedUrl = doc.getStringSafe("embedUrl"), - url = doc.getStringSafe("url"), - youtubeId = doc.getStringSafe("youtubeId"), - images = doc.get("images", Document::class.java)?.let { documentToImages(it) } ?: Images() +fun documentToAnimeBroadcast(doc: Document): AnimeBroadcast { + return AnimeBroadcast( + day = doc.getStringSafe("day"), + time = doc.getStringSafe("time"), + timezone = doc.getStringSafe("timezone") + ) +} + +fun documentToScore(doc: Document): Score { + return Score( + percentage = when (val value = doc["percentage"]) { + is Double -> value + is Int -> value.toDouble() + else -> 0.0 + }, + score = doc.getIntSafe("score", 0), + votes = doc.getIntSafe("votes", 0) ) } @@ -228,7 +253,7 @@ fun documentToAnimeTopEntity(doc: Document) = AnimeTopEntity( subtype = doc.getStringSafe("subtype"), ) -fun documentToAnimeLastEpisodeEntity(doc: Document) = LastEpisodeData( +fun documentToAnimeLastEpisodeEntity(doc: Document) = LastEpisodeEntity( malId = doc.getIntSafe("malId"), title = doc.getStringSafe("title"), image = doc.getStringSafe("image"), @@ -290,15 +315,6 @@ fun documentToAnimeDirectoryEntity(doc: Document) = AnimeTypeEntity( season = doc.getStringSafe("season") ) - -fun documentToAnimesEntity(doc: Document) = AnimesEntity( - year = doc.getIntSafe("year"), - slug = doc.getStringSafe("slug"), - name = doc.getStringSafe("name"), - image = doc.getStringSafe("image"), - season = doc.getStringSafe("season") -) - fun documentToAnimesThemeEntity(doc: Document) = Anime( year = doc.getIntSafe("year"), slug = doc.getStringSafe("slug"), diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/AlternativeTitles.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/AlternativeTitles.kt deleted file mode 100644 index 1f48c3a..0000000 --- a/src/main/kotlin/com/jeluchu/features/anime/models/anime/AlternativeTitles.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.jeluchu.features.anime.models.anime - -import kotlinx.serialization.Serializable - -@Serializable -data class AlternativeTitles( - /** - * Title for anime. - */ - val title: String = "", - - /** - * Title type for anime. - */ - val type: String = "" -) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/Character.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/Character.kt index f0f9eb8..07887b0 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/models/anime/Character.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/Character.kt @@ -4,7 +4,10 @@ import kotlinx.serialization.Serializable @Serializable data class Character( - var character: Individual = Individual(), + val malId: Int = 0, + val url: String = "", + val name: String = "", + val images: String = "", var role: String = "", var voiceActor: List = emptyList() ) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/EpisodeDurationEntity.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/EpisodeDurationEntity.kt new file mode 100644 index 0000000..d218afd --- /dev/null +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/EpisodeDurationEntity.kt @@ -0,0 +1,9 @@ +package com.jeluchu.features.anime.models.anime + +import kotlinx.serialization.Serializable + +@Serializable +data class EpisodeDurationEntity( + var unit: String? = null, + var value: Int? = null +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/EpisodeInfo.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/EpisodeInfo.kt new file mode 100644 index 0000000..f201714 --- /dev/null +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/EpisodeInfo.kt @@ -0,0 +1,18 @@ +package com.jeluchu.features.anime.models.anime + +import kotlinx.serialization.Serializable + +@Serializable +data class EpisodeInfo( + val number: Int? = null, + val seasonNumber: Int? = null, + val relativeNumber: Int? = null, + val airdate: String? = null, + val duration: Int? = null, + val thumbnail: String? = null, + val synopsis: MultipleLanguage? = null, + val titles: MultipleLanguageTitles? = null, + var score: Double? = null, + var filler: Boolean? = false, + var recap: Boolean? = false +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/ImageMediaEntity.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/ImageMediaEntity.kt deleted file mode 100644 index 2c3fc63..0000000 --- a/src/main/kotlin/com/jeluchu/features/anime/models/anime/ImageMediaEntity.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.jeluchu.features.anime.models.anime - -import kotlinx.serialization.Serializable - -@Serializable - data class ImageMediaEntity( - val media: String, - val thumbnail: String, - val width: Int, - val height: Int, - val url: String - ) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/MergedEpisode.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MergedEpisode.kt deleted file mode 100644 index 0708da5..0000000 --- a/src/main/kotlin/com/jeluchu/features/anime/models/anime/MergedEpisode.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.jeluchu.features.anime.models.anime - -import kotlinx.serialization.Serializable - -@Serializable -data class MergedEpisode( - var malId: Int, - var title: String, - var titleJapanese: String, - var titleRomanji: String, - var aired: String, - var score: Float, - var filler: Boolean, - var recap: Boolean, -) - diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/MoreInfoEntity.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MoreInfoEntity.kt index 0d9dd4c..ae7ca10 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/models/anime/MoreInfoEntity.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MoreInfoEntity.kt @@ -1,52 +1,39 @@ package com.jeluchu.features.anime.models.anime import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString -import kotlinx.serialization.json.Json -import org.bson.Document @Serializable data class MoreInfoEntity( - var malId: Int = 0, - val id: String = "", + val id: String? = null, + var malId: Int? = null, + val rank: Int? = null, var title: String = "", - var poster: String = "", - var cover: String = "", - var genres: List = emptyList(), - var synopsis: String = "", - var episodes: List = emptyList(), - var episodesCount: Int = 0, - var score: String = "", - var staff: List = emptyList(), - var characters: List = emptyList(), - var status: String = "", + var episodes: Int? = null, + var episodeList: List? = null, var type: String = "", - val url: String = "", - val promo: VideoPromo? = VideoPromo(), - val duration: String = "", - val rank: Int = 0, - val titles: List = emptyList(), - val airing: Boolean = false, - val aired: AiringTime = AiringTime(), - val broadcast: AnimeBroadcast = AnimeBroadcast(), - val season: String = "", - val year: Int = 0, - val external: List = emptyList(), - val streaming: List = emptyList(), - val studios: List = emptyList(), - val licensors: List = emptyList(), - val producers: List = emptyList(), - val theme: Themes = Themes(), - val relations: List = emptyList(), - val stats: Statistics = Statistics(), - val gallery: List = emptyList(), - val episodeSource: String = "" -) { - fun toDocument(): Document = Document.parse(Json.encodeToString(this)) - - companion object { - private val json = Json { ignoreUnknownKeys = true } - - fun fromDocument(document: Document): MoreInfoEntity = json.decodeFromString(document.toJson()) - } -} \ No newline at end of file + var status: String = "", + var season: SeasonalEntity? = null, + var poster: String = "", + var cover: String? = null, + var duration: EpisodeDurationEntity? = null, + var score: String? = null, + var titles: OtherTitlesEntity? = null, + val studios: List? = null, + val producers: List? = null, + val licensors: List? = null, + val relations: List? = null, + val promo: VideoPromo? = null, + var tags: MultipleLanguageLists? = null, + var synopsis: MultipleLanguage? = null, + var staff: List? = null, + var characters: List? = null, + val streaming: List? = null, + val urls: List? = null, + val broadcast: AnimeBroadcast? = null, + val external: List? = null, + val stats: Statistics? = null, + val nsfw: Boolean = false, + val ageRating: String? = null, + val aired: AiringTime? = null, + val themes: Themes? = null +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/AnimeSource.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguage.kt similarity index 55% rename from src/main/kotlin/com/jeluchu/features/anime/models/anime/AnimeSource.kt rename to src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguage.kt index 99fdd14..8097fbc 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/models/anime/AnimeSource.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguage.kt @@ -3,8 +3,7 @@ package com.jeluchu.features.anime.models.anime import kotlinx.serialization.Serializable @Serializable -data class AnimeSource( - val id: String, - val source: String -) - +data class MultipleLanguage( + val es: String? = null, + val en: String? = null +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguageLists.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguageLists.kt new file mode 100644 index 0000000..cae62ac --- /dev/null +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguageLists.kt @@ -0,0 +1,9 @@ +package com.jeluchu.features.anime.models.anime + +import kotlinx.serialization.Serializable + +@Serializable +data class MultipleLanguageLists( + val es: List? = null, + val en: List? = null +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguageTitles.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguageTitles.kt new file mode 100644 index 0000000..379eaac --- /dev/null +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/MultipleLanguageTitles.kt @@ -0,0 +1,11 @@ +package com.jeluchu.features.anime.models.anime + +import kotlinx.serialization.Serializable + +@Serializable +data class MultipleLanguageTitles( + val es: String? = null, + val en: String? = null, + val jp: String? = null, + val romaji_jp: String? = null, +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/OtherTitlesEntity.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/OtherTitlesEntity.kt new file mode 100644 index 0000000..d8ab922 --- /dev/null +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/OtherTitlesEntity.kt @@ -0,0 +1,9 @@ +package com.jeluchu.features.anime.models.anime + +import kotlinx.serialization.Serializable + +@Serializable +data class OtherTitlesEntity( + var synonyms: List? = null, + var abbreviatedTitles: List? = null +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/anime/SeasonalEntity.kt b/src/main/kotlin/com/jeluchu/features/anime/models/anime/SeasonalEntity.kt new file mode 100644 index 0000000..2d4e6bf --- /dev/null +++ b/src/main/kotlin/com/jeluchu/features/anime/models/anime/SeasonalEntity.kt @@ -0,0 +1,9 @@ +package com.jeluchu.features.anime.models.anime + +import kotlinx.serialization.Serializable + +@Serializable +data class SeasonalEntity( + var station: String? = null, + var year: Int? = null +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/episodes/EpisodeEntity.kt b/src/main/kotlin/com/jeluchu/features/anime/models/episodes/EpisodeEntity.kt new file mode 100644 index 0000000..79ae30a --- /dev/null +++ b/src/main/kotlin/com/jeluchu/features/anime/models/episodes/EpisodeEntity.kt @@ -0,0 +1,15 @@ +package com.jeluchu.features.anime.models.episodes + +import com.jeluchu.core.models.jikan.anime.AnimeData +import kotlinx.serialization.Serializable + +@Serializable +data class EpisodeEntity( + val malId: Int = 0, + val title: String?, + val score: String?, + val image: String?, + val day: String?, + val time: String?, + val timezone: String?, +) \ No newline at end of file diff --git a/src/main/kotlin/com/jeluchu/features/anime/models/lastepisodes/LastEpisodeData.kt b/src/main/kotlin/com/jeluchu/features/anime/models/lastepisodes/LastEpisodeEntity.kt similarity index 88% rename from src/main/kotlin/com/jeluchu/features/anime/models/lastepisodes/LastEpisodeData.kt rename to src/main/kotlin/com/jeluchu/features/anime/models/lastepisodes/LastEpisodeEntity.kt index f4b25fa..92f68b0 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/models/lastepisodes/LastEpisodeData.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/models/lastepisodes/LastEpisodeEntity.kt @@ -4,7 +4,7 @@ import com.jeluchu.core.models.jikan.anime.AnimeData import kotlinx.serialization.Serializable @Serializable -data class LastEpisodeData( +data class LastEpisodeEntity( val malId: Int = 0, val title: String?, val score: String?, @@ -14,7 +14,7 @@ data class LastEpisodeData( val timezone: String?, ) { companion object { - fun AnimeData.toLastEpisodeData() = LastEpisodeData( + fun AnimeData.toLastEpisodeData() = LastEpisodeEntity( malId = malId ?: 0, day = broadcast?.day.orEmpty(), time = broadcast?.time.orEmpty(), diff --git a/src/main/kotlin/com/jeluchu/features/anime/services/AnimeService.kt b/src/main/kotlin/com/jeluchu/features/anime/services/AnimeService.kt index 971d2ba..d105caa 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/services/AnimeService.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/services/AnimeService.kt @@ -8,8 +8,8 @@ import com.jeluchu.core.extensions.update import com.jeluchu.core.messages.ErrorMessages import com.jeluchu.core.models.ErrorResponse import com.jeluchu.core.models.PaginationResponse -import com.jeluchu.features.anime.models.lastepisodes.LastEpisodeData -import com.jeluchu.features.anime.models.lastepisodes.LastEpisodeData.Companion.toLastEpisodeData +import com.jeluchu.features.anime.models.lastepisodes.LastEpisodeEntity +import com.jeluchu.features.anime.models.lastepisodes.LastEpisodeEntity.Companion.toLastEpisodeData import com.jeluchu.core.models.jikan.search.AnimeSearch import com.jeluchu.core.utils.BaseUrls import com.jeluchu.core.utils.Collections @@ -35,8 +35,7 @@ class AnimeService( private val database: MongoDatabase ) { private val timers = database.getCollection(Collections.TIMERS) - private val directoryCollection = database.getCollection(Collections.ANIME_DETAILS) - private val lastEpisodesCollection = database.getCollection(Collections.LAST_EPISODES) + private val directoryCollection = database.getCollection(Collections.ANIME_DIRECTORY) suspend fun getDirectory(call: RoutingCall) = try { val type = call.request.queryParameters["type"].orEmpty() @@ -116,7 +115,7 @@ class AnimeService( AnimeSearch.serializer() ) - val animes = mutableListOf() + val animes = mutableListOf() val totalPage = response.pagination?.lastPage ?: 0 response.data?.map { it.toLastEpisodeData() }.orEmpty().let { animes.addAll(it) } @@ -130,7 +129,7 @@ class AnimeService( delay(1000) } - val documentsToInsert = parseDataToDocuments(animes, LastEpisodeData.serializer()) + val documentsToInsert = parseDataToDocuments(animes, LastEpisodeEntity.serializer()) if (documentsToInsert.isNotEmpty()) collection.insertMany(documentsToInsert) timers.update(timerKey) diff --git a/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt b/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt index aa223e7..eedb973 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt @@ -8,7 +8,6 @@ import com.jeluchu.core.models.PaginationResponse import com.jeluchu.core.utils.Collections import com.jeluchu.core.utils.TimerKey import com.jeluchu.features.anime.mappers.documentToAnimeDirectoryEntity -import com.jeluchu.features.anime.mappers.documentToAnimeTypeEntity import com.mongodb.client.MongoCollection import com.mongodb.client.MongoDatabase import com.mongodb.client.model.Filters @@ -23,7 +22,7 @@ import org.bson.conversions.Bson class DirectoryService( private val database: MongoDatabase, private val timers: MongoCollection = database.getCollection(Collections.TIMERS), - private val directory: MongoCollection = database.getCollection(Collections.ANIME_DETAILS) + private val directory: MongoCollection = database.getCollection(Collections.ANIME_DIRECTORY) ) { suspend fun getAnimeByType(call: RoutingCall) { val param = call.getStringSafeParam("type").uppercase() diff --git a/src/main/kotlin/com/jeluchu/features/themes/services/AnimeThemesService.kt b/src/main/kotlin/com/jeluchu/features/themes/services/AnimeThemesService.kt index 3b3b9da..361d122 100644 --- a/src/main/kotlin/com/jeluchu/features/themes/services/AnimeThemesService.kt +++ b/src/main/kotlin/com/jeluchu/features/themes/services/AnimeThemesService.kt @@ -5,7 +5,6 @@ import com.jeluchu.core.extensions.getIntSafeQueryParam import com.jeluchu.core.messages.ErrorMessages import com.jeluchu.core.models.PaginationResponse import com.jeluchu.core.utils.Collections -import com.jeluchu.features.anime.mappers.documentToAnimesEntity import com.jeluchu.features.anime.mappers.documentToAnimesThemeEntity import com.mongodb.client.MongoDatabase import io.ktor.http.*