sane-tag-music: prefer existing artist/albumartist tags over path-based ones

This commit is contained in:
2024-07-09 19:36:45 +00:00
parent 2011065497
commit afc31dfc2f

View File

@@ -190,10 +190,6 @@ class Tags:
albumartist=merge_field(self.albumartist, fallback.albumartist)
tracknumber=merge_field(self.tracknumber, fallback.tracknumber)
if artist == albumartist:
# if extraneous, then keep the album artist whatever it originally was
albumartist = self.albumartist
return Tags(
artist=artist,
album=album,
@@ -246,17 +242,19 @@ class Tags:
"""
if loose_compare_lists(self.artist, self.albumartist):
# arist & album artist are nearly identical:
# artist & album artist are nearly identical:
# probably guessed one of them from filename, which was lacking certain symbols of the actual artist.
# recover whichever of these fields had the fewer characters removed (i.e. is longest)
if len("".join(self.artist)) > len("".join(self.albumartist)):
self.artist = self.albumartist = self.artist
else:
self.artist = self.albumartist = self.albumartist
self.albumartist = self.artist
elif self.albumartist == [clean_for_fs(a) for a in self.albumartist] and self.artist != [clean_for_fs(a) for a in self.artist]:
# the album artist was taken from disk (bad), but the artist was provided in some way that preserves more info
self.albumartist = self.artist
elif self.albumartist and all(self.albumartist):
self.artist = self.albumartist
if self.artist == []:
self.artist = self.albumartist
self.albumartist = []
def rewrite_singles(self) -> None:
""" idiom is for singles to belong to self-titled album. else each artist's singles get merged into one massive album """
@@ -568,7 +566,6 @@ class Tagger:
if self.manual_tags.tracknumber == [""]:
# special case that `--trackno ""` can be used to delete the track number without `--force`ing all fields
new_tags.tracknumber = []
new_tags = new_tags.union(self.manual_tags)
new_tags.trim_fields()
new_tags.cleanup_trackno()
new_tags.expand_shorthands()