fix: catch NullPointerException
in BaseItemDto
to FindroidEpisode
conversion
This error is caused by the seriesId or seasonId being null. Hide these episodes for now. Closes #357 Closes #360
This commit is contained in:
parent
fd33d52bba
commit
1c117d3c66
2 changed files with 30 additions and 26 deletions
|
@ -35,34 +35,38 @@ data class FindroidEpisode(
|
||||||
suspend fun BaseItemDto.toFindroidEpisode(
|
suspend fun BaseItemDto.toFindroidEpisode(
|
||||||
jellyfinRepository: JellyfinRepository,
|
jellyfinRepository: JellyfinRepository,
|
||||||
database: ServerDatabaseDao? = null
|
database: ServerDatabaseDao? = null
|
||||||
): FindroidEpisode {
|
): FindroidEpisode? {
|
||||||
val sources = mutableListOf<FindroidSource>()
|
val sources = mutableListOf<FindroidSource>()
|
||||||
sources.addAll(mediaSources?.map { it.toFindroidSource(jellyfinRepository, id) } ?: emptyList())
|
sources.addAll(mediaSources?.map { it.toFindroidSource(jellyfinRepository, id) } ?: emptyList())
|
||||||
if (database != null) {
|
if (database != null) {
|
||||||
sources.addAll(database.getSources(id).map { it.toFindroidSource(database) })
|
sources.addAll(database.getSources(id).map { it.toFindroidSource(database) })
|
||||||
}
|
}
|
||||||
return FindroidEpisode(
|
return try {
|
||||||
id = id,
|
FindroidEpisode(
|
||||||
name = name.orEmpty(),
|
id = id,
|
||||||
originalTitle = originalTitle,
|
name = name.orEmpty(),
|
||||||
overview = overview.orEmpty(),
|
originalTitle = originalTitle,
|
||||||
indexNumber = indexNumber ?: 0,
|
overview = overview.orEmpty(),
|
||||||
indexNumberEnd = indexNumberEnd,
|
indexNumber = indexNumber ?: 0,
|
||||||
parentIndexNumber = parentIndexNumber ?: 0,
|
indexNumberEnd = indexNumberEnd,
|
||||||
sources = sources,
|
parentIndexNumber = parentIndexNumber ?: 0,
|
||||||
played = userData?.played ?: false,
|
sources = sources,
|
||||||
favorite = userData?.isFavorite ?: false,
|
played = userData?.played ?: false,
|
||||||
canPlay = playAccess != PlayAccess.NONE,
|
favorite = userData?.isFavorite ?: false,
|
||||||
canDownload = canDownload ?: false,
|
canPlay = playAccess != PlayAccess.NONE,
|
||||||
runtimeTicks = runTimeTicks ?: 0,
|
canDownload = canDownload ?: false,
|
||||||
playbackPositionTicks = userData?.playbackPositionTicks ?: 0L,
|
runtimeTicks = runTimeTicks ?: 0,
|
||||||
premiereDate = premiereDate,
|
playbackPositionTicks = userData?.playbackPositionTicks ?: 0L,
|
||||||
seriesName = seriesName.orEmpty(),
|
premiereDate = premiereDate,
|
||||||
seriesId = seriesId!!,
|
seriesName = seriesName.orEmpty(),
|
||||||
seasonId = seasonId!!,
|
seriesId = seriesId!!,
|
||||||
communityRating = communityRating,
|
seasonId = seasonId!!,
|
||||||
missing = locationType == LocationType.VIRTUAL,
|
communityRating = communityRating,
|
||||||
)
|
missing = locationType == LocationType.VIRTUAL,
|
||||||
|
)
|
||||||
|
} catch (_: NullPointerException) {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FindroidEpisodeDto.toFindroidEpisode(database: ServerDatabaseDao, userId: UUID): FindroidEpisode {
|
fun FindroidEpisodeDto.toFindroidEpisode(database: ServerDatabaseDao, userId: UUID): FindroidEpisode {
|
||||||
|
|
|
@ -74,7 +74,7 @@ class JellyfinRepositoryImpl(
|
||||||
jellyfinApi.userLibraryApi.getItem(
|
jellyfinApi.userLibraryApi.getItem(
|
||||||
jellyfinApi.userId!!,
|
jellyfinApi.userId!!,
|
||||||
itemId
|
itemId
|
||||||
).content.toFindroidEpisode(this@JellyfinRepositoryImpl, database)
|
).content.toFindroidEpisode(this@JellyfinRepositoryImpl, database)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getMovie(itemId: UUID): FindroidMovie =
|
override suspend fun getMovie(itemId: UUID): FindroidMovie =
|
||||||
|
@ -254,7 +254,7 @@ class JellyfinRepositoryImpl(
|
||||||
seriesId = seriesId?.toString(),
|
seriesId = seriesId?.toString(),
|
||||||
).content.items
|
).content.items
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
.map { it.toFindroidEpisode(this@JellyfinRepositoryImpl) }
|
.mapNotNull { it.toFindroidEpisode(this@JellyfinRepositoryImpl) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getEpisodes(
|
override suspend fun getEpisodes(
|
||||||
|
@ -276,7 +276,7 @@ class JellyfinRepositoryImpl(
|
||||||
limit = limit,
|
limit = limit,
|
||||||
).content.items
|
).content.items
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
.map { it.toFindroidEpisode(this@JellyfinRepositoryImpl, database) }
|
.mapNotNull { it.toFindroidEpisode(this@JellyfinRepositoryImpl, database) }
|
||||||
} else {
|
} else {
|
||||||
database.getEpisodesBySeasonId(seasonId).map { it.toFindroidEpisode(database, jellyfinApi.userId!!) }
|
database.getEpisodesBySeasonId(seasonId).map { it.toFindroidEpisode(database, jellyfinApi.userId!!) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue