2020-10-08 22:20:20 +02:00
package org.mosad.teapod.util
2021-09-05 00:08:03 +02:00
import java.util.Locale
2020-12-26 14:39:35 +01:00
2020-10-11 23:16:47 +02:00
class DataTypes {
enum class MediaType {
OTHER ,
MOVIE ,
TVSHOW
}
2020-11-23 20:11:10 +01:00
enum class Theme ( val str : String ) {
LIGHT ( " Light " ) ,
DARK ( " Dark " )
}
2020-12-05 21:03:14 +01:00
enum class License ( val short : String , val long : String ) {
APACHE2 ( " AL 2.0 " , " Apache License Version 2.0 " ) ,
MIT ( " MIT " , " MIT License " ) ,
GPL3 ( " GPL 3 " , " GNU General Public License Version 3 " ) ,
BSD2 ( " BSD 2 " , " BSD 2-Clause License " )
}
2020-10-11 23:16:47 +02:00
}
2020-12-05 21:03:14 +01:00
data class ThirdPartyComponent (
val name : String ,
val year : String ,
val copyrightOwner : String ,
val link : String ,
val license : DataTypes . License
)
2020-10-16 19:56:08 +02:00
/ * *
* this class is used to represent the item media
* it is uses in the ItemMediaAdapter ( RecyclerView )
* /
data class ItemMedia (
2021-07-25 19:15:31 +02:00
val id : Int , // aod path id
2020-10-15 18:57:58 +02:00
val title : String ,
2020-10-16 19:56:08 +02:00
val posterUrl : String
)
2021-08-31 19:47:18 +02:00
// TODO replace playlist: List<AoDEpisode> with a map?
data class AoDMedia (
val aodId : Int ,
val type : DataTypes . MediaType ,
val title : String ,
val shortText : String ,
val posterURL : String ,
var year : Int ,
var age : Int ,
val similar : List < ItemMedia > ,
val playlist : List < AoDEpisode > ,
) {
fun getEpisodeById ( mediaId : Int ) = playlist . firstOrNull { it . mediaId == mediaId }
?: AoDEpisodeNone
}
data class AoDEpisode (
val mediaId : Int ,
val title : String ,
val description : String ,
val shortDesc : String ,
val imageURL : String ,
2021-09-05 00:08:03 +02:00
val numberStr : String ,
val index : Int ,
2021-08-31 19:47:18 +02:00
var watched : Boolean ,
val watchedCallback : String ,
val streams : MutableList < Stream > ,
) {
fun hasDub ( ) = streams . any { it . language == Locale . GERMAN }
/ * *
* get the preferred stream
* @return the preferred stream , if not present use the first stream
* /
fun getPreferredStream ( language : Locale ) = streams . firstOrNull { it . language == language }
?: streams . first ( )
}
2021-09-04 13:33:46 +02:00
data class Stream (
val url : String ,
val language : Locale
)
2021-08-31 19:47:18 +02:00
// TODO will be watched info (state and callback) -> remove description and number
data class AoDEpisodeInfo (
val aodMediaId : Int ,
val shortDesc : String ,
var watched : Boolean ,
val watchedCallback : String ,
)
val AoDMediaNone = AoDMedia (
- 1 ,
DataTypes . MediaType . OTHER ,
" " ,
" " ,
" " ,
- 1 ,
- 1 ,
listOf ( ) ,
listOf ( )
)
val AoDEpisodeNone = AoDEpisode (
- 1 ,
" " ,
" " ,
" " ,
" " ,
2021-09-05 00:08:03 +02:00
" " ,
2021-08-31 19:47:18 +02:00
- 1 ,
false ,
" " ,
mutableListOf ( )
)
2020-12-26 14:39:35 +01:00
/ * *
* this class is used to represent the aod json API ?
* /
2021-07-25 19:15:31 +02:00
data class AoDPlaylist (
val list : List < Playlist > ,
2021-07-25 19:30:25 +02:00
val language : Locale
2020-12-26 14:39:35 +01:00
)
2020-10-19 21:57:02 +02:00
data class Playlist (
val sources : List < Source > ,
val image : String ,
val title : String ,
val description : String ,
val mediaid : Int
)
data class Source (
val file : String = " "
)