Lots of changes for series

This commit is contained in:
Damontecres 2025-09-30 10:55:32 -04:00
parent d7dde352bc
commit 62f557988e
No known key found for this signature in database
34 changed files with 1956 additions and 216 deletions

View file

@ -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(