From 7fbdf56c6b6b8318974e4add6446e15654df4bea Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Tue, 26 Dec 2023 02:20:27 +0100 Subject: [PATCH] fix: prevent error when sorting an artist's tracks ...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 --- mopidy_beets/library.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mopidy_beets/library.py b/mopidy_beets/library.py index 674c85b..ae164ca 100644 --- a/mopidy_beets/library.py +++ b/mopidy_beets/library.py @@ -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( + 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 = []