Skip to content

Commit

Permalink
Consider artist names before album artist names
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Nov 2, 2024
1 parent b0d5a78 commit ef4e2b5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ fun NowPlayingComposable() {
) {
// Name
Text(text = item?.name.orEmpty(), maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(text = item?.albumArtist.orEmpty(), maxLines = 1, overflow = TextOverflow.Ellipsis)
val artists = item?.artists ?: item?.albumArtists ?: item?.albumArtist?.let(::listOf)
Text(text = artists?.joinToString(", ").orEmpty(), maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ open class BaseItemDtoBaseRowItem @JvmOverloads constructor(
}

override fun getCardName(context: Context) = when {
baseItem?.type == BaseItemKind.AUDIO && baseItem.artists != null -> baseItem.artists?.joinToString(", ")
baseItem?.type == BaseItemKind.AUDIO && baseItem.albumArtists != null -> baseItem.albumArtists?.joinToString(", ")
baseItem?.type == BaseItemKind.AUDIO && baseItem.albumArtist != null -> baseItem.albumArtist
baseItem?.type == BaseItemKind.AUDIO && baseItem.album != null -> baseItem.album
else -> baseItem?.getFullName(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fun BaseItemDto.getSeasonEpisodeName(context: Context): String {
&& parentIndexNumber != null
&& parentIndexNumber != 0 ->
context.getString(R.string.lbl_season_number, parentIndexNumber)

else -> null
}

Expand Down Expand Up @@ -69,11 +70,13 @@ fun BaseItemDto.getProgramSubText(context: Context) = buildString {
append(TimeUtils.getFriendlyDate(context, startDate), " ")

// Add the start and end time
append(context.getString(
R.string.lbl_time_range,
context.getTimeFormatter().format(startDate),
context.getTimeFormatter().format(endDate),
))
append(
context.getString(
R.string.lbl_time_range,
context.getTimeFormatter().format(startDate),
context.getTimeFormatter().format(endDate),
)
)
}

fun BaseItemDto.getFirstPerson(searchedType: PersonKind) = people?.firstOrNull { it.type == searchedType }
Expand All @@ -97,9 +100,11 @@ fun BaseItemDto.getFullName(context: Context): String? = when (type) {
}.filterNot { it.isNullOrBlank() }.joinToString(" ")
// we actually want the artist name if available
BaseItemKind.AUDIO,
BaseItemKind.MUSIC_ALBUM -> listOfNotNull(albumArtist, name)
.filter { it.isNotEmpty() }
.joinToString(" - ")
BaseItemKind.MUSIC_ALBUM -> listOfNotNull(
artists?.joinToString(", ") ?: albumArtists?.joinToString(", ") ?: albumArtist,
name
).filter { it.isNotEmpty() }.joinToString(" - ")

else -> name
}

Expand All @@ -111,16 +116,20 @@ fun BaseItemDto.getSubName(context: Context): String? = when (type) {
name,
TimeUtils.getFriendlyDate(context, premiereDate)
)

else -> name
}

BaseItemKind.SEASON -> when {
childCount != null && childCount!! > 0 -> context.getQuantityString(R.plurals.episodes, childCount!!)
else -> ""
}

BaseItemKind.MUSIC_ALBUM -> when {
childCount != null && childCount!! > 0 -> context.getQuantityString(R.plurals.tracks, childCount!!)
else -> ""
}

BaseItemKind.AUDIO -> name
else -> officialRating
}
Expand All @@ -137,6 +146,7 @@ fun BaseItemDto.buildChapterItems(api: ApiClient): List<ChapterItemInfo> = chapt
tag = dto.imageTag,
imageIndex = i,
)

else -> null
},
)
Expand Down

0 comments on commit ef4e2b5

Please sign in to comment.