Skip to content

Commit

Permalink
fix: prevent error when sorting an artist's tracks
Browse files Browse the repository at this point in the history
...by falling back to using `0` when a sort key is `None`.
This makes the artist detail view also show up when one of the artist's tracks is missing a field that is used for sorting.

Closes #42
  • Loading branch information
mgoltzsche committed Jan 11, 2024
1 parent dfb1160 commit 7fbdf56
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mopidy_beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ def lookup(self, uri=None, uris=None):
)
# Append composer tracks to the artist tracks (unique items).
tracks = list(set(artist_tracks + composer_tracks))
tracks.sort(key=lambda t: (t.date, t.disc_no, t.track_no))
tracks.sort(

Check warning on line 169 in mopidy_beets/library.py

View check run for this annotation

Codecov / codecov/patch

mopidy_beets/library.py#L169

Added line #L169 was not covered by tests
key=lambda t: (t.date or 0, t.disc_no or 0, t.track_no or 0)
)
else:
logger.info("Unknown Beets lookup URI: %s", uri)
tracks = []
Expand Down

0 comments on commit 7fbdf56

Please sign in to comment.