Improve tagging on rescan

This commit is contained in:
Keith Edmunds 2021-08-22 20:40:13 +01:00
parent 4267901630
commit 9dfc5e50cc
2 changed files with 18 additions and 4 deletions

View File

@ -153,7 +153,12 @@ class Window(QMainWindow, Ui_MainWindow):
if record.f_int != self.y():
record.update(session, {'f_int': self.y()})
self.visible_playlist_tab().close(session)
# Find a playlist tab (as opposed to an info tab) and
# save column widths
if self.current_track_playlist_tab:
self.current_track_playlist_tab.close(session)
elif self.next_track_playlist_tab:
self.next_track_playlist_tab.close(session)
event.accept()

View File

@ -6,6 +6,7 @@ import shutil
import tempfile
from config import Config
from helpers import show_warning
from log import DEBUG, INFO
from model import Notes, Playdates, PlaylistTracks, Session, Tracks
from mutagen.flac import FLAC
@ -369,15 +370,23 @@ def update_meta(session, track, artist=None, title=None):
INFO(f"File type {ftype} not implemented")
return
# Update tags
f = tag_handler(track.path)
with Session() as session:
try:
if artist:
f["artist"] = artist
Tracks.update_artist(session, track.id, artist)
if title:
f["title"] = title
Tracks.update_title(session, track.id, title)
f.save()
except TypeError:
show_warning("TAG error", "Can't update tag. Try editing in Audacity")
# Update database
with Session() as session:
if artist:
Tracks.update_artist(session, track.id, artist)
if title:
Tracks.update_title(session, track.id, title)
if __name__ == '__main__' and '__file__' in globals():