Lots of changes for series
This commit is contained in:
parent
d7dde352bc
commit
62f557988e
34 changed files with 1956 additions and 216 deletions
|
|
@ -1,11 +1,13 @@
|
|||
package com.github.damontecres.dolphin.data.model
|
||||
|
||||
import com.github.damontecres.dolphin.ui.components.details.SeasonEpisode
|
||||
import com.github.damontecres.dolphin.ui.nav.Destination
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.extensions.imageApi
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
import org.jellyfin.sdk.model.api.BaseItemKind
|
||||
import org.jellyfin.sdk.model.api.ImageType
|
||||
|
||||
@Serializable
|
||||
|
|
@ -19,7 +21,37 @@ data class BaseItem(
|
|||
|
||||
@Transient val name = data.name
|
||||
|
||||
fun destination() = Destination.MediaItem(id, type, this)
|
||||
fun destination(): Destination.MediaItem {
|
||||
val result =
|
||||
// Redirect episodes & seasons to their series if possible
|
||||
when (type) {
|
||||
BaseItemKind.EPISODE -> {
|
||||
data.indexNumber?.let { episode ->
|
||||
data.parentIndexNumber?.let { season ->
|
||||
Destination.MediaItem(
|
||||
data.seriesId!!,
|
||||
BaseItemKind.SERIES,
|
||||
this,
|
||||
SeasonEpisode(season, episode),
|
||||
)
|
||||
}
|
||||
} ?: Destination.MediaItem(id, type, this)
|
||||
}
|
||||
|
||||
BaseItemKind.SEASON ->
|
||||
data.parentIndexNumber?.let { season ->
|
||||
Destination.MediaItem(
|
||||
data.seriesId!!,
|
||||
BaseItemKind.SERIES,
|
||||
this,
|
||||
SeasonEpisode(season, 0),
|
||||
)
|
||||
} ?: Destination.MediaItem(id, type, this)
|
||||
|
||||
else -> Destination.MediaItem(id, type, this)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun from(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue