rework how different streams/languages per episode are handled
* potentially support more than 2 streams * part of language settings in player
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
package org.mosad.teapod.util
|
||||
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class DataTypes {
|
||||
enum class MediaType {
|
||||
OTHER,
|
||||
@ -47,7 +50,10 @@ data class Media(
|
||||
val type: DataTypes.MediaType,
|
||||
val info: Info = Info(),
|
||||
var episodes: ArrayList<Episode> = arrayListOf()
|
||||
)
|
||||
) {
|
||||
fun hasEpisode(id: Int) = episodes.any { it.id == id }
|
||||
fun getEpisodeById(id: Int) = episodes.first { it.id == id }
|
||||
}
|
||||
|
||||
data class Info(
|
||||
var title: String = "",
|
||||
@ -60,23 +66,37 @@ data class Info(
|
||||
)
|
||||
|
||||
/**
|
||||
* if secStreamOmU == true, then a secondary stream is present
|
||||
* number = episode number (0..n)
|
||||
*/
|
||||
data class Episode(
|
||||
val id: Int = 0,
|
||||
val streams: MutableList<Stream> = mutableListOf(),
|
||||
var title: String = "",
|
||||
var priStreamUrl: String = "",
|
||||
var secStreamUrl: String = "",
|
||||
var secStreamOmU: Boolean = false,
|
||||
var posterUrl: String = "",
|
||||
var description: String = "",
|
||||
var shortDesc: String = "",
|
||||
var number: Int = 0,
|
||||
var watched: Boolean = false,
|
||||
var watchedCallback: String = ""
|
||||
) {
|
||||
/**
|
||||
* 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
|
||||
)
|
||||
|
||||
/**
|
||||
* this class is used for tmdb responses
|
||||
*/
|
||||
data class TMDBResponse(
|
||||
val id: Int = 0,
|
||||
val title: String = "",
|
||||
@ -86,7 +106,13 @@ data class TMDBResponse(
|
||||
var runtime: Int = 0
|
||||
)
|
||||
|
||||
data class AoDObject(val playlist: List<Playlist>)
|
||||
/**
|
||||
* this class is used to represent the aod json API?
|
||||
*/
|
||||
data class AoDObject(
|
||||
val playlist: List<Playlist>,
|
||||
val extLanguage: String
|
||||
)
|
||||
|
||||
data class Playlist(
|
||||
val sources: List<Source>,
|
||||
|
@ -23,10 +23,10 @@ class EpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerView.Ada
|
||||
val context = holder.binding.root.context
|
||||
val ep = episodes[position]
|
||||
|
||||
val titleText = if (ep.priStreamUrl.isEmpty() && ep.secStreamOmU) {
|
||||
context.getString(R.string.component_episode_title_sub, ep.number, ep.description)
|
||||
} else {
|
||||
val titleText = if (ep.hasDub()) {
|
||||
context.getString(R.string.component_episode_title, ep.number, ep.description)
|
||||
} else {
|
||||
context.getString(R.string.component_episode_title_sub, ep.number, ep.description)
|
||||
}
|
||||
|
||||
holder.binding.textEpisodeTitle.text = titleText
|
||||
|
@ -22,10 +22,10 @@ class PlayerEpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerVi
|
||||
val context = holder.binding.root.context
|
||||
val ep = episodes[position]
|
||||
|
||||
val titleText = if (ep.priStreamUrl.isEmpty() && ep.secStreamOmU) {
|
||||
context.getString(R.string.component_episode_title_sub, ep.number, ep.description)
|
||||
} else {
|
||||
val titleText = if (ep.hasDub()) {
|
||||
context.getString(R.string.component_episode_title, ep.number, ep.description)
|
||||
} else {
|
||||
context.getString(R.string.component_episode_title_sub, ep.number, ep.description)
|
||||
}
|
||||
|
||||
holder.binding.textEpisodeTitle2.text = titleText
|
||||
|
Reference in New Issue
Block a user