Playlist deals with invalid track_id
This commit is contained in:
parent
5d1078dea0
commit
1ce009ee73
@ -1051,6 +1051,19 @@ class PlaylistTab(QTableWidget):
|
|||||||
track = None
|
track = None
|
||||||
if track_id:
|
if track_id:
|
||||||
track = session.get(Tracks, track_id)
|
track = session.get(Tracks, track_id)
|
||||||
|
if not track:
|
||||||
|
# We have a track_id but we can't find the track.
|
||||||
|
# Update playlist_row accordingly
|
||||||
|
missing_track = playlist_row.track_id
|
||||||
|
playlist_row.track_id = None
|
||||||
|
if note_text:
|
||||||
|
note_text += f"track_id {missing_track} not found"
|
||||||
|
else:
|
||||||
|
note_text = f"track_id {missing_track} not found"
|
||||||
|
playlist_row.note = note_text
|
||||||
|
session.commit()
|
||||||
|
note_item = QTableWidgetItem(note_text)
|
||||||
|
self.setItem(row, HEADER_NOTES_COLUMN, note_item)
|
||||||
|
|
||||||
if track:
|
if track:
|
||||||
# Reset colour in case it was current/next/unplayable
|
# Reset colour in case it was current/next/unplayable
|
||||||
@ -1402,7 +1415,10 @@ class PlaylistTab(QTableWidget):
|
|||||||
def _get_note_text_time(text: str) -> Optional[datetime]:
|
def _get_note_text_time(text: str) -> Optional[datetime]:
|
||||||
"""Return time specified as @hh:mm:ss in text"""
|
"""Return time specified as @hh:mm:ss in text"""
|
||||||
|
|
||||||
|
try:
|
||||||
match = start_time_re.search(text)
|
match = start_time_re.search(text)
|
||||||
|
except TypeError:
|
||||||
|
return None
|
||||||
if not match:
|
if not match:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user