2021-07-17 13:15:14 +02:00
/ * *
* Teapod
*
2022-01-02 17:59:23 +01:00
* Copyright 2020 - 2022 < seil0 @mosad . xyz >
2021-07-17 13:15:14 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston ,
* MA 02110 - 1301 , USA .
*
* /
2021-07-10 23:37:16 +02:00
package org.mosad.teapod.util.tmdb
2022-01-02 17:51:45 +01:00
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
2021-07-17 13:15:14 +02:00
/ * *
* These data classes represent the tmdb api json objects .
* Fields which are nullable in the tmdb api are also nullable here .
* /
2021-12-31 16:03:15 +01:00
interface TMDBResult {
val id : Int
val name : String
val overview : String ? // for movies tmdb return string or null
val posterPath : String ?
val backdropPath : String ?
2021-07-10 23:37:16 +02:00
}
2021-12-31 16:03:15 +01:00
data class TMDBBase (
2021-07-10 23:37:16 +02:00
override val id : Int ,
2021-07-17 13:15:14 +02:00
override val name : String ,
override val overview : String ? ,
override val posterPath : String ? ,
2021-12-31 16:03:15 +01:00
override val backdropPath : String ?
) : TMDBResult
2022-01-02 17:51:45 +01:00
/ * *
* search results for movie and tv show
* /
@Serializable
data class TMDBSearch < T > (
val page : Int ,
val results : List < T >
)
@Serializable
data class TMDBSearchResultMovie (
@SerialName ( " id " ) override val id : Int ,
@SerialName ( " title " ) override val name : String ,
@SerialName ( " overview " ) override val overview : String ? ,
@SerialName ( " poster_path " ) override val posterPath : String ? ,
@SerialName ( " backdrop_path " ) override val backdropPath : String ? ,
) : TMDBResult
@Serializable
data class TMDBSearchResultTVShow (
@SerialName ( " id " ) override val id : Int ,
@SerialName ( " name " ) override val name : String ,
@SerialName ( " overview " ) override val overview : String ? ,
@SerialName ( " poster_path " ) override val posterPath : String ? ,
@SerialName ( " backdrop_path " ) override val backdropPath : String ? ,
) : TMDBResult
val NoneTMDBSearch = TMDBSearch < TMDBBase > ( 0 , emptyList ( ) )
val NoneTMDBSearchMovie = TMDBSearch < TMDBSearchResultMovie > ( 0 , emptyList ( ) )
val NoneTMDBSearchTVShow = TMDBSearch < TMDBSearchResultTVShow > ( 0 , emptyList ( ) )
/ * *
* detail return data types
* /
2021-12-31 16:03:15 +01:00
@Serializable
data class TMDBMovie (
@SerialName ( " id " ) override val id : Int ,
@SerialName ( " title " ) override val name : String , // for movies the name is in the field title
@SerialName ( " overview " ) override val overview : String ? ,
@SerialName ( " poster_path " ) override val posterPath : String ? ,
@SerialName ( " backdrop_path " ) override val backdropPath : String ? ,
@SerialName ( " release_date " ) val releaseDate : String ,
@SerialName ( " runtime " ) val runtime : Int ? ,
@SerialName ( " status " ) val status : String ,
2021-07-10 23:37:16 +02:00
// TODO generes
2021-12-31 16:03:15 +01:00
) : TMDBResult
2021-07-10 23:37:16 +02:00
2021-12-31 16:03:15 +01:00
@Serializable
2021-07-25 19:15:31 +02:00
data class TMDBTVShow (
2021-12-31 16:03:15 +01:00
@SerialName ( " id " ) override val id : Int ,
@SerialName ( " name " ) override val name : String ,
@SerialName ( " overview " ) override val overview : String ,
@SerialName ( " poster_path " ) override val posterPath : String ? ,
@SerialName ( " backdrop_path " ) override val backdropPath : String ? ,
@SerialName ( " first_air_date " ) val firstAirDate : String ,
@SerialName ( " last_air_date " ) val lastAirDate : String ,
@SerialName ( " status " ) val status : String ,
2021-07-10 23:37:16 +02:00
// TODO generes
2021-12-31 16:03:15 +01:00
) : TMDBResult
// use null for nullable types, the gui needs to handle/implement a fallback for null values
val NoneTMDB = TMDBBase ( 0 , " " , " " , null , null )
2022-03-05 20:41:39 +01:00
val NoneTMDBMovie = TMDBMovie ( 0 , " " , " " , null , null , " 1970-01-01 " , null , " " )
val NoneTMDBTVShow = TMDBTVShow ( 0 , " " , " " , null , null , " 1970-01-01 " , " 1970-01-01 " , " " )
2021-07-10 23:37:16 +02:00
2021-12-31 16:03:15 +01:00
@Serializable
2021-07-25 19:15:31 +02:00
data class TMDBTVSeason (
2021-12-31 16:03:15 +01:00
@SerialName ( " id " ) val id : Int ,
@SerialName ( " name " ) val name : String ,
@SerialName ( " overview " ) val overview : String ,
@SerialName ( " poster_path " ) val posterPath : String ? ,
@SerialName ( " air_date " ) val airDate : String ,
@SerialName ( " episodes " ) val episodes : List < TMDBTVEpisode > ,
@SerialName ( " season_number " ) val seasonNumber : Int
2021-07-10 23:37:16 +02:00
)
2021-12-31 16:03:15 +01:00
@Serializable
2021-07-25 19:15:31 +02:00
data class TMDBTVEpisode (
2021-12-31 16:03:15 +01:00
@SerialName ( " id " ) val id : Int ,
@SerialName ( " name " ) val name : String ,
@SerialName ( " overview " ) val overview : String ,
@SerialName ( " air_date " ) val airDate : String ,
@SerialName ( " episode_number " ) val episodeNumber : Int
)
// use null for nullable types, the gui needs to handle/implement a fallback for null values
val NoneTMDBTVSeason = TMDBTVSeason ( 0 , " " , " " , null , " " , emptyList ( ) , 0 )