Don't select unplayable track as next track

This commit is contained in:
Keith Edmunds 2025-01-10 20:27:26 +00:00
parent 3a3b1b712d
commit d30bf49c88

View File

@ -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: