Skip to content

Commit

Permalink
Fix ModelCompat crash for media type
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed May 26, 2024
1 parent f49b5af commit ead9df8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ fun LegacyBaseItemDto.asSdk(): ModernBaseItemDto = ModernBaseItemDto(
chapters = this.chapters?.map { it.asSdk() },
locationType = this.locationType?.asSdk(),
isoType = this.isoType?.asSdk(),
mediaType = MediaType.fromName(this.mediaType.lowercase().replaceFirstChar { it.uppercase() }),
mediaType = this.mediaType?.let {
MediaType.fromName(
it.lowercase().replaceFirstChar { it.uppercase() })
} ?: MediaType.UNKNOWN,
endDate = this.endDate?.toLocalDateTime(),
lockedFields = this.lockedFields?.map { it.asSdk() },
trailerCount = this.trailerCount,
Expand Down Expand Up @@ -286,7 +289,8 @@ private fun ModernDayOfWeek.Companion.from(str: String) = when (str.uppercase())
else -> null
}

private fun Date.toLocalDateTime(): LocalDateTime = toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()
private fun Date.toLocalDateTime(): LocalDateTime =
toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()

private fun LegacyExtraType.asSdk(): ExtraType = when (this) {
LegacyExtraType.Clip -> ExtraType.CLIP
Expand Down

0 comments on commit ead9df8

Please sign in to comment.