This commit is contained in:
Benjamin Schaaf
2022-01-11 02:55:35 +11:00
parent 5ce4f1c944
commit c7b0bc0bc8
2 changed files with 22 additions and 10 deletions

View File

@@ -191,7 +191,7 @@ class AppConfiguration(DataClassJsonMixin):
if self.version < 6: if self.version < 6:
self.player_config = { self.player_config = {
"Local Playback": {"Replay Gain": ["no", "track", "album"][self._rg]}, "Local Playback": {"Replay Gain": ["Disabled", "Track", "Album"][self._rg]},
"Chromecast": { "Chromecast": {
"Serve Local Files to Chromecasts on the LAN": self._sol, "Serve Local Files to Chromecasts on the LAN": self._sol,
"LAN Server Port Number": self._pn, "LAN Server Port Number": self._pn,

View File

@@ -279,6 +279,9 @@ class ArtistDetailPanel(Gtk.Box):
self.artist_stats_long = self.make_label(name="artist-stats") self.artist_stats_long = self.make_label(name="artist-stats")
artist_stats_squeezer.add(self.artist_stats_long) artist_stats_squeezer.add(self.artist_stats_long)
self.artist_stats_medium = self.make_label(name="artist-stats")
artist_stats_squeezer.add(self.artist_stats_medium)
self.artist_stats_short = self.make_label(name="artist-stats") self.artist_stats_short = self.make_label(name="artist-stats")
artist_stats_squeezer.add(self.artist_stats_short) artist_stats_squeezer.add(self.artist_stats_short)
@@ -360,8 +363,9 @@ class ArtistDetailPanel(Gtk.Box):
self.artist_name.set_markup(bleach.clean(f"<b>{artist.name}</b>")) self.artist_name.set_markup(bleach.clean(f"<b>{artist.name}</b>"))
self.artist_name.set_tooltip_text(artist.name) self.artist_name.set_tooltip_text(artist.name)
self.artist_stats_long.set_markup(self.format_stats(artist, short=False)) self.artist_stats_long.set_markup(self.format_stats(artist, short_time=False))
self.artist_stats_short.set_markup(self.format_stats(artist, short=True)) self.artist_stats_medium.set_markup(self.format_stats(artist, short_time=True))
self.artist_stats_short.set_markup(self.format_stats(artist, short_time=True, short_count=True))
biography = "" biography = ""
if artist.biography: if artist.biography:
@@ -504,19 +508,27 @@ class ArtistDetailPanel(Gtk.Box):
label=text, name=name, halign=Gtk.Align.START, xalign=0, **params label=text, name=name, halign=Gtk.Align.START, xalign=0, **params
) )
def format_stats(self, artist: API.Artist, short=False) -> str: def format_stats(self, artist: API.Artist, short_time=False, short_count=False) -> str:
album_count = artist.album_count or len(artist.albums or []) album_count = artist.album_count or len(artist.albums or [])
song_count, duration = 0, timedelta(0) song_count, duration = 0, timedelta(0)
for album in artist.albums or []: for album in artist.albums or []:
song_count += album.song_count or 0 song_count += album.song_count or 0
duration += album.duration or timedelta(0) duration += album.duration or timedelta(0)
return util.dot_join( parts = []
"{} {}".format(album_count, util.pluralize("album", album_count)),
"{} {}".format(song_count, util.pluralize("song", song_count)), if short_count:
util.format_song_duration(duration) parts.append(f"{album_count}/{song_count}")
if short else util.format_sequence_duration(duration), else:
) parts.append("{} {}".format(album_count, util.pluralize("album", album_count)))
parts.append("{} {}".format(song_count, util.pluralize("song", song_count)))
if short_time:
parts.append(util.format_song_duration(duration))
else:
parts.append(util.format_sequence_duration(duration))
return util.dot_join(*parts)
def get_artist_song_ids(self) -> List[str]: def get_artist_song_ids(self) -> List[str]:
try: try: