2020-10-08 22:20:20 +02:00
package org.mosad.teapod.util
2020-12-26 14:39:35 +01:00
import java.util.*
import kotlin.collections.ArrayList
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 (
val id : Int ,
2020-10-15 18:57:58 +02:00
val title : String ,
2020-10-16 19:56:08 +02:00
val posterUrl : String
)
/ * *
* TODO the episodes workflow could use a clean up / rework
* /
data class Media (
val id : Int ,
2020-10-15 18:57:58 +02:00
val link : String ,
val type : DataTypes . MediaType ,
val info : Info = Info ( ) ,
2020-12-26 20:09:35 +01:00
val episodes : ArrayList < Episode > = arrayListOf ( )
2020-12-26 14:39:35 +01:00
) {
fun hasEpisode ( id : Int ) = episodes . any { it . id == id }
fun getEpisodeById ( id : Int ) = episodes . first { it . id == id }
}
2020-10-11 23:16:47 +02:00
2021-02-06 19:02:12 +01:00
// TODO all val?
2020-10-13 16:30:23 +02:00
data class Info (
2020-10-16 19:56:08 +02:00
var title : String = " " ,
var posterUrl : String = " " ,
2020-10-13 16:30:23 +02:00
var shortDesc : String = " " ,
var description : String = " " ,
var year : Int = 0 ,
var age : Int = 0 ,
2021-02-06 19:02:12 +01:00
var episodesCount : Int = 0 ,
var similar : List < ItemMedia > = listOf ( )
2020-10-13 16:30:23 +02:00
)
2020-10-12 20:30:45 +02:00
2020-10-19 21:57:02 +02:00
/ * *
2020-12-15 23:15:14 +01:00
* number = episode number ( 0. . n )
2020-10-19 21:57:02 +02:00
* /
2020-10-13 16:30:23 +02:00
data class Episode (
2020-12-28 20:45:52 +01:00
val id : Int = - 1 ,
2020-12-26 14:39:35 +01:00
val streams : MutableList < Stream > = mutableListOf ( ) ,
2020-12-26 20:09:35 +01:00
val title : String = " " ,
val posterUrl : String = " " ,
val description : String = " " ,
2020-10-13 20:23:55 +02:00
var shortDesc : String = " " ,
2020-12-26 20:09:35 +01:00
val number : Int = 0 ,
2020-10-13 23:47:48 +02:00
var watched : Boolean = false ,
var watchedCallback : String = " "
2020-12-26 14:39:35 +01:00
) {
/ * *
* 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 ( )
fun hasDub ( ) = streams . any { it . language == Locale . GERMAN }
}
data class Stream (
val url : String ,
val language : Locale
2020-10-13 16:30:23 +02:00
)
2020-10-13 15:56:07 +02:00
2020-12-26 14:39:35 +01:00
/ * *
* this class is used for tmdb responses
2021-02-06 19:02:12 +01:00
* TODO why is runtime var ?
2020-12-26 14:39:35 +01:00
* /
2020-10-13 16:30:23 +02:00
data class TMDBResponse (
val id : Int = 0 ,
val title : String = " " ,
val overview : String = " " ,
val posterUrl : String = " " ,
val backdropUrl : String = " " ,
var runtime : Int = 0
)
2020-10-19 21:57:02 +02:00
2020-12-26 14:39:35 +01:00
/ * *
* this class is used to represent the aod json API ?
* /
data class AoDObject (
val playlist : List < Playlist > ,
val extLanguage : String
)
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 = " "
)