From d00cdace14728736a5ee4ac72f093a75db89ac93 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Sat, 20 Apr 2024 16:43:22 +0200 Subject: [PATCH] Move part of the code from load_selection() to new _load_selection_nat() --- picard/ui/searchdialog/track.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/picard/ui/searchdialog/track.py b/picard/ui/searchdialog/track.py index a446a3018..8048a01d1 100644 --- a/picard/ui/searchdialog/track.py +++ b/picard/ui/searchdialog/track.py @@ -198,6 +198,22 @@ class TrackSearchDialog(SearchDialog): # No files associated. Just a normal search. self.tagger.load_album(track['musicbrainz_albumid']) + def _load_selection_nat(self, track, node): + if self.file_: + # Search is performed for a file. + if getattr(self.file_.parent, 'album', None): + # Have to move that file from its existing album to NAT. + album = self.file_.parent.album + self.tagger.move_file_to_nat(self.file_, track['musicbrainz_recordingid'], node) + if album.get_num_total_files() == 0: + self.tagger.remove_album(album) + else: + # No parent album + self.tagger.move_file_to_nat(self.file_, track['musicbrainz_recordingid'], node) + else: + # No files associated. Just a normal search + self.tagger.load_nat(track['musicbrainz_recordingid'], node) + def load_selection(self, row): """Load the album corresponding to the selected track. If the search is performed for a file, also associate the file to @@ -210,17 +226,4 @@ class TrackSearchDialog(SearchDialog): self._load_selection_non_nat(track, node) else: # Track is a Non Album Track (NAT) - if self.file_: - # Search is performed for a file. - if getattr(self.file_.parent, 'album', None): - # Have to move that file from its existing album to NAT. - album = self.file_.parent.album - self.tagger.move_file_to_nat(self.file_, track['musicbrainz_recordingid'], node) - if album.get_num_total_files() == 0: - self.tagger.remove_album(album) - else: - # No parent album - self.tagger.move_file_to_nat(self.file_, track['musicbrainz_recordingid'], node) - else: - # No files associated. Just a normal search - self.tagger.load_nat(track['musicbrainz_recordingid'], node) + self._load_selection_nat(track, node)