diff --git a/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt b/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt index eb04ee84..f86f038e 100644 --- a/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt +++ b/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt @@ -280,8 +280,8 @@ class InMemoryAppContentRepository @Inject constructor( // library detail screen via loadLibraryContent, and on the // home rows by loadSuggestions / loadContinueWatching / // loadLatestLibraryContent. - librariesItem.map { dto -> - val library = dto.toLibrary(serverUrl()) + librariesItem.mapNotNull { dto -> + val library = dto.toLibrary(serverUrl()) ?: return@mapNotNull null val count = jellyfinApiClient.getLibraryItemCount(library.id) ?: library.size when (library.type) { LibraryKind.MOVIES -> library.copy(movies = emptyList(), size = count) diff --git a/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt b/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt index 2af465bb..42e6247d 100644 --- a/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt +++ b/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt @@ -11,12 +11,13 @@ import hu.bbara.purefin.model.Season import hu.bbara.purefin.model.Series import org.jellyfin.sdk.model.api.BaseItemDto import org.jellyfin.sdk.model.api.CollectionType +import timber.log.Timber import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.Locale import java.util.concurrent.TimeUnit -fun BaseItemDto.toLibrary(serverUrl: String): Library { +fun BaseItemDto.toLibrary(serverUrl: String): Library? { return when (collectionType) { CollectionType.MOVIES -> Library( id = id, @@ -42,10 +43,20 @@ fun BaseItemDto.toLibrary(serverUrl: String): Library { size = childCount ?: 0, series = emptyList(), ) - else -> throw UnsupportedOperationException("Unsupported library type: $collectionType") + else -> { + // Jellyfin servers can return other top-level views (e.g. boxsets, + // music, photos, live TV) that this app does not surface on the + // home dashboard. Skip them so a single unsupported view does + // not abort the whole refresh and leave the user with an empty + // home screen. + Timber.tag(TAG).w("Skipping unsupported library type: $collectionType") + null + } } } +private const val TAG = "BaseItemDtoConverter" + fun BaseItemDto.toMovie(serverUrl: String): Movie { return Movie( id = id,