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
|
--trackno TRACK_NUMBER
|
||||||
|
|
||||||
fix-tags options:
|
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
|
from dataclasses import dataclass
|
||||||
@@ -539,14 +539,14 @@ class Tagger:
|
|||||||
|
|
||||||
old_tags = file_.tags_on_disk()
|
old_tags = file_.tags_on_disk()
|
||||||
path_tags = Tags.from_path(path_)
|
path_tags = Tags.from_path(path_)
|
||||||
additional_tags = self.manual_tags.union(path_tags)
|
|
||||||
if self.force:
|
if self.force:
|
||||||
# additional_tags overrule old_tags
|
# manual_tags > path_tags > old_tags
|
||||||
new_tags = additional_tags.union(old_tags)
|
new_tags = self.manual_tags.union(path_tags).union(old_tags)
|
||||||
else:
|
else:
|
||||||
# old_tags overrule additional_tags
|
# manual_tags > old_tags > path_tags
|
||||||
new_tags = old_tags.union(additional_tags)
|
# old_tags overrule path_tags
|
||||||
if additional_tags.tracknumber == [""]:
|
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
|
# special case that `--trackno ""` can be used to delete the track number without `--force`ing all fields
|
||||||
new_tags.tracknumber = []
|
new_tags.tracknumber = []
|
||||||
new_tags = new_tags.union(self.manual_tags)
|
new_tags = new_tags.union(self.manual_tags)
|
||||||
|
Reference in New Issue
Block a user