Fix music artist listing & show music in collections (#1739)
## Description Switches to use the Artists API instead of Items API when fetching the list of artists in a library. Enables fetching artists, albums, and music videos in a collection. Also adds titles for the remaining `BaseItemKind` types for future proofing even if they aren't used anywhere in the app. ### Related issues Fixes #1733 Fixes #1734 Fixes #1735 ### Testing Emulator, created a new collection with the above. Also verified the artist query against the web UI ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
00490b14ec
commit
5bc874a9ff
9 changed files with 134 additions and 35 deletions
|
|
@ -230,36 +230,36 @@ fun formatTypeName(type: BaseItemKind): Int =
|
|||
BaseItemKind.PLAYLIST -> R.string.playlists
|
||||
BaseItemKind.PERSON -> R.string.people_title
|
||||
BaseItemKind.BOX_SET -> R.string.collections
|
||||
BaseItemKind.AUDIO -> TODO()
|
||||
BaseItemKind.AUDIO -> R.string.songs
|
||||
BaseItemKind.CHANNEL -> R.string.channels
|
||||
BaseItemKind.GENRE -> R.string.genres
|
||||
BaseItemKind.LIVE_TV_CHANNEL -> R.string.channels
|
||||
BaseItemKind.MUSIC_ALBUM -> TODO()
|
||||
BaseItemKind.MUSIC_ARTIST -> TODO()
|
||||
BaseItemKind.MUSIC_GENRE -> TODO()
|
||||
BaseItemKind.MUSIC_VIDEO -> TODO()
|
||||
BaseItemKind.MUSIC_ALBUM -> R.string.albums
|
||||
BaseItemKind.MUSIC_ARTIST -> R.string.artists
|
||||
BaseItemKind.MUSIC_GENRE -> R.string.genres
|
||||
BaseItemKind.MUSIC_VIDEO -> R.string.music_videos
|
||||
BaseItemKind.PHOTO -> R.string.photos
|
||||
BaseItemKind.PHOTO_ALBUM -> TODO()
|
||||
BaseItemKind.PROGRAM -> TODO()
|
||||
BaseItemKind.RECORDING -> TODO()
|
||||
BaseItemKind.PHOTO_ALBUM -> R.string.photos
|
||||
BaseItemKind.PROGRAM -> R.string.programs
|
||||
BaseItemKind.RECORDING -> R.string.recordings
|
||||
BaseItemKind.SEASON -> R.string.tv_seasons
|
||||
BaseItemKind.STUDIO -> R.string.studios
|
||||
BaseItemKind.TRAILER -> R.string.trailers_title
|
||||
BaseItemKind.TV_CHANNEL -> R.string.channels
|
||||
BaseItemKind.TV_PROGRAM -> TODO()
|
||||
BaseItemKind.USER_ROOT_FOLDER -> TODO()
|
||||
BaseItemKind.USER_VIEW -> TODO()
|
||||
BaseItemKind.YEAR -> TODO()
|
||||
BaseItemKind.AGGREGATE_FOLDER -> TODO()
|
||||
BaseItemKind.AUDIO_BOOK -> TODO()
|
||||
BaseItemKind.BASE_PLUGIN_FOLDER -> TODO()
|
||||
BaseItemKind.BOOK -> TODO()
|
||||
BaseItemKind.CHANNEL_FOLDER_ITEM -> TODO()
|
||||
BaseItemKind.COLLECTION_FOLDER -> TODO()
|
||||
BaseItemKind.FOLDER -> TODO()
|
||||
BaseItemKind.MANUAL_PLAYLISTS_FOLDER -> TODO()
|
||||
BaseItemKind.LIVE_TV_PROGRAM -> TODO()
|
||||
BaseItemKind.PLAYLISTS_FOLDER -> TODO()
|
||||
BaseItemKind.TV_PROGRAM -> R.string.programs
|
||||
BaseItemKind.USER_ROOT_FOLDER -> R.string.folders_title
|
||||
BaseItemKind.USER_VIEW -> R.string.user_views
|
||||
BaseItemKind.YEAR -> R.string.year
|
||||
BaseItemKind.AGGREGATE_FOLDER -> R.string.folders_title
|
||||
BaseItemKind.AUDIO_BOOK -> R.string.audio_books
|
||||
BaseItemKind.BASE_PLUGIN_FOLDER -> R.string.folders_title
|
||||
BaseItemKind.BOOK -> R.string.books
|
||||
BaseItemKind.CHANNEL_FOLDER_ITEM -> R.string.folders_title
|
||||
BaseItemKind.COLLECTION_FOLDER -> R.string.library
|
||||
BaseItemKind.FOLDER -> R.string.folders_title
|
||||
BaseItemKind.MANUAL_PLAYLISTS_FOLDER -> R.string.playlists
|
||||
BaseItemKind.LIVE_TV_PROGRAM -> R.string.programs
|
||||
BaseItemKind.PLAYLISTS_FOLDER -> R.string.playlists
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ import com.github.damontecres.wholphin.ui.tryRequestFocus
|
|||
import com.github.damontecres.wholphin.util.ApiRequestPager
|
||||
import com.github.damontecres.wholphin.util.DataLoadingState
|
||||
import com.github.damontecres.wholphin.util.ExceptionHandler
|
||||
import com.github.damontecres.wholphin.util.GetArtistsHandler
|
||||
import com.github.damontecres.wholphin.util.GetItemsRequestHandler
|
||||
import com.github.damontecres.wholphin.util.GetPersonsHandler
|
||||
import com.github.damontecres.wholphin.util.LoadingState
|
||||
|
|
@ -92,6 +93,7 @@ import org.jellyfin.sdk.model.api.CollectionType
|
|||
import org.jellyfin.sdk.model.api.ImageType
|
||||
import org.jellyfin.sdk.model.api.ItemSortBy
|
||||
import org.jellyfin.sdk.model.api.SortOrder
|
||||
import org.jellyfin.sdk.model.api.request.GetArtistsRequest
|
||||
import org.jellyfin.sdk.model.api.request.GetItemsRequest
|
||||
import org.jellyfin.sdk.model.api.request.GetPersonsRequest
|
||||
import org.jellyfin.sdk.model.serializer.toUUID
|
||||
|
|
@ -373,6 +375,26 @@ class CollectionFolderViewModel
|
|||
)
|
||||
newPager
|
||||
}
|
||||
|
||||
GetItemsFilterOverride.ARTIST -> {
|
||||
val item = state.value.item.successValue
|
||||
val request =
|
||||
filter.applyTo(
|
||||
GetArtistsRequest(
|
||||
parentId = item?.id,
|
||||
enableImageTypes = listOf(ImageType.PRIMARY, ImageType.THUMB),
|
||||
),
|
||||
)
|
||||
val newPager =
|
||||
ApiRequestPager(
|
||||
api,
|
||||
request,
|
||||
GetArtistsHandler,
|
||||
viewModelScope,
|
||||
useSeriesForPrimary = useSeriesForPrimary,
|
||||
)
|
||||
newPager
|
||||
}
|
||||
}
|
||||
|
||||
private fun createGetItemsRequest(
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.github.damontecres.wholphin.data.ServerRepository
|
|||
import com.github.damontecres.wholphin.data.model.BaseItem
|
||||
import com.github.damontecres.wholphin.data.model.CollectionFolderFilter
|
||||
import com.github.damontecres.wholphin.data.model.GetItemsFilter
|
||||
import com.github.damontecres.wholphin.data.model.GetItemsFilterOverride
|
||||
import com.github.damontecres.wholphin.preferences.UserPreferences
|
||||
import com.github.damontecres.wholphin.services.BackdropService
|
||||
import com.github.damontecres.wholphin.services.MusicService
|
||||
|
|
@ -203,7 +204,7 @@ fun CollectionFolderMusic(
|
|||
CollectionFolderFilter(
|
||||
filter =
|
||||
GetItemsFilter(
|
||||
includeItemTypes = listOf(BaseItemKind.MUSIC_ARTIST),
|
||||
override = GetItemsFilterOverride.ARTIST,
|
||||
),
|
||||
),
|
||||
showTitle = false,
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ fun CollectionDetailsContent(
|
|||
onClickPlay = onClickPlay,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
onFocusPosition = { position ->
|
||||
Timber.v("onFocusPosition=%s", position)
|
||||
// Timber.v("onFocusPosition=%s", position)
|
||||
focusedItem =
|
||||
position.let {
|
||||
val key =
|
||||
|
|
|
|||
|
|
@ -51,18 +51,45 @@ fun CollectionRows(
|
|||
if (row is HomeRowLoadingState.Success) {
|
||||
// TODO not great to do this in the UI
|
||||
val viewOptions =
|
||||
if (type == BaseItemKind.EPISODE) {
|
||||
HomeRowViewOptions(
|
||||
heightDp = Cards.HEIGHT_EPISODE,
|
||||
episodeAspectRatio = AspectRatio.WIDE,
|
||||
showTitles = cardViewOptions.showTitles,
|
||||
useSeries = false,
|
||||
)
|
||||
} else {
|
||||
HomeRowViewOptions(
|
||||
showTitles = cardViewOptions.showTitles,
|
||||
)
|
||||
when (type) {
|
||||
BaseItemKind.EPISODE -> {
|
||||
HomeRowViewOptions(
|
||||
heightDp = Cards.HEIGHT_EPISODE,
|
||||
episodeAspectRatio = AspectRatio.WIDE,
|
||||
showTitles = cardViewOptions.showTitles,
|
||||
useSeries = false,
|
||||
)
|
||||
}
|
||||
|
||||
BaseItemKind.MUSIC_ARTIST,
|
||||
BaseItemKind.MUSIC_ALBUM,
|
||||
BaseItemKind.PLAYLIST,
|
||||
BaseItemKind.AUDIO,
|
||||
-> {
|
||||
HomeRowViewOptions(
|
||||
heightDp = Cards.HEIGHT_EPISODE,
|
||||
aspectRatio = AspectRatio.SQUARE,
|
||||
showTitles = cardViewOptions.showTitles,
|
||||
)
|
||||
}
|
||||
|
||||
BaseItemKind.VIDEO,
|
||||
BaseItemKind.MUSIC_VIDEO,
|
||||
-> {
|
||||
HomeRowViewOptions(
|
||||
heightDp = Cards.HEIGHT_EPISODE,
|
||||
aspectRatio = AspectRatio.WIDE,
|
||||
showTitles = cardViewOptions.showTitles,
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
HomeRowViewOptions(
|
||||
showTitles = cardViewOptions.showTitles,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
row.copy(viewOptions = viewOptions)
|
||||
} else {
|
||||
row
|
||||
|
|
|
|||
|
|
@ -489,6 +489,9 @@ class CollectionViewModel
|
|||
BaseItemKind.EPISODE,
|
||||
BaseItemKind.VIDEO,
|
||||
BaseItemKind.BOX_SET,
|
||||
BaseItemKind.MUSIC_ARTIST,
|
||||
BaseItemKind.MUSIC_ALBUM,
|
||||
BaseItemKind.MUSIC_VIDEO,
|
||||
)
|
||||
|
||||
const val VIEW_OPTIONS_KEY = "CollectionViewOptions"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue