From 4edcab15421fc7929dd771297c574ba9aa0fc3dc Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sun, 1 Jan 2023 11:08:37 +0000 Subject: [PATCH] Skip over unreadable tracks when selecting next track. --- app/playlists.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/playlists.py b/app/playlists.py index 85751a7..82d002a 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -1284,7 +1284,12 @@ class PlaylistTab(QTableWidget): session, self.playlist_id) ] for row in range(starting_row, self.rowCount()): - if row not in track_rows or row in played_rows: + plr = self._get_playlistrow_object(session, row) + if ( + row not in track_rows or + row in played_rows or + not file_is_readable(plr.track.path) + ): continue else: return row @@ -1325,6 +1330,12 @@ class PlaylistTab(QTableWidget): return playlistrow_id + def _get_playlistrow_object(self, session: Session, row: int) -> int: + """Return the playlistrow object associated with this row""" + + playlistrow_id = (self.item(row, USERDATA).data(self.PLAYLISTROW_ID)) + return session.get(PlaylistRows, playlistrow_id) + def _get_row_artist(self, row: int) -> Optional[str]: """Return artist on this row or None if none""" @@ -1755,7 +1766,6 @@ class PlaylistTab(QTableWidget): # Check track is readable if not file_is_readable(track.path): - self._set_unreadable_row(row_number) return None # Notify musicmuster @@ -1763,6 +1773,7 @@ class PlaylistTab(QTableWidget): self.musicmuster.this_is_the_next_playlist_row(session, plr, self) # Update display + self.clear_selection() self.update_display(session) def _set_played_row(self, session: Session, row: int) -> None: