sane-tag-music: improve fix-tags
behavior so that manual tags tag precedence over existing tags
This commit is contained in:
@@ -59,7 +59,7 @@ options:
|
||||
--trackno TRACK_NUMBER
|
||||
|
||||
fix-tags options:
|
||||
--force: apply path-based tag to each file, even those which already have tags (only for fix-tags)
|
||||
--force: apply path-based tag to each file, even those which already have tags
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
@@ -539,14 +539,14 @@ class Tagger:
|
||||
|
||||
old_tags = file_.tags_on_disk()
|
||||
path_tags = Tags.from_path(path_)
|
||||
additional_tags = self.manual_tags.union(path_tags)
|
||||
if self.force:
|
||||
# additional_tags overrule old_tags
|
||||
new_tags = additional_tags.union(old_tags)
|
||||
# manual_tags > path_tags > old_tags
|
||||
new_tags = self.manual_tags.union(path_tags).union(old_tags)
|
||||
else:
|
||||
# old_tags overrule additional_tags
|
||||
new_tags = old_tags.union(additional_tags)
|
||||
if additional_tags.tracknumber == [""]:
|
||||
# manual_tags > old_tags > path_tags
|
||||
# old_tags overrule path_tags
|
||||
new_tags = self.manual_tags.union(old_tags).union(path_tags)
|
||||
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)
|
||||
|
Reference in New Issue
Block a user