Skip to content

Commit

Permalink
hide books/podcasts without the audiocontent
Browse files Browse the repository at this point in the history
  • Loading branch information
GrakovNe committed Dec 11, 2024
1 parent f6cbc86 commit d2a38b0
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class LibraryPageResponseConverter @Inject constructor() {
.mapNotNull {
val title = it.media.metadata.title ?: return@mapNotNull null

val hasMediaItems = (it.media.numAudioFiles ?: 0) > 0
if (hasMediaItems.not()) {
return@mapNotNull null
}

Book(
id = it.id,
title = title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ import javax.inject.Singleton
class LibrarySearchItemsConverter @Inject constructor() {
fun apply(response: List<LibraryItem>) = response
.mapNotNull {
val title = it.media.metadata.title ?: return@mapNotNull null

val hasMediaItems = (it.media.numAudioFiles ?: 0) > 0
if (hasMediaItems.not()) {
return@mapNotNull null
}

Book(
id = it.id,
title = it.media.metadata.title ?: return@mapNotNull null,
title = title,
author = it.media.metadata.authorName,
duration = it.media.duration.toInt(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data class BookResponse(
data class BookMedia(
val metadata: LibraryMetadataResponse,
val audioFiles: List<BookAudioFileResponse>?,
val chapters: List<LibraryChapterResponse>?,
val chapters: List<LibraryChapterResponse>?
)

data class LibraryMetadataResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class LibraryItem(
data class Media(
val duration: Double,
val metadata: LibraryMetadata,
val numAudioFiles: Int?
)

data class LibraryMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class PodcastPageResponseConverter @Inject constructor() {
.mapNotNull {
val title = it.media.metadata.title ?: return@mapNotNull null

val hasMediaItems = (it.media.numAudioFiles ?: 0) > 0
if (hasMediaItems.not()) {
return@mapNotNull null
}

Book(
id = it.id,
title = title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class PodcastSearchItemsConverter @Inject constructor() {
.mapNotNull {
val title = it.media.metadata.title ?: return@mapNotNull null

val hasMediaItems = (it.media.numAudioFiles ?: 0) > 0
if (hasMediaItems.not()) {
return@mapNotNull null
}

Book(
id = it.id,
title = title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class PodcastItem(
data class PodcastItemMedia(
val duration: Double,
val metadata: PodcastMetadata,
val numAudioFiles: Int?
)

data class PodcastMetadata(
Expand Down

0 comments on commit d2a38b0

Please sign in to comment.