From d30bf49c88ee54ee4addbf244d26996a8c9b7f29 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Fri, 10 Jan 2025 20:27:26 +0000 Subject: [PATCH] Don't select unplayable track as next track --- app/playlistmodel.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/playlistmodel.py b/app/playlistmodel.py index 70232f9..cb2c05e 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -297,22 +297,17 @@ class PlaylistModel(QAbstractTableModel): self.update_track_times() # Find next track - # Get all unplayed track rows - log.debug(f"{self}: Find next track") next_row = None - unplayed_rows = self.get_unplayed_rows() + unplayed_rows = [ + a + for a in self.get_unplayed_rows() + if not self.is_header_row(a) + and not file_is_unreadable(self.playlist_rows[a].path) + ] if unplayed_rows: try: - # Find next row after current track - next_row = min( - [ - a - for a in unplayed_rows - if a > row_number and not self.is_header_row(a) - ] - ) + next_row = min([a for a in unplayed_rows if a > row_number]) except ValueError: - # Find first unplayed track next_row = min(unplayed_rows) if next_row is not None: self.set_next_row(next_row) @@ -1588,7 +1583,9 @@ class PlaylistModel(QAbstractTableModel): row(s), otherwise insert this track at row_number. """ - track_rows = [a.row_number for a in self.playlist_rows.values() if a.track_id == track_id] + track_rows = [ + a.row_number for a in self.playlist_rows.values() if a.track_id == track_id + ] if track_rows: with db.Session() as session: for row in track_rows: