sane-tag-music: --trackno "" fix-tags FOO
can be used to clear FOOs track number field
This commit is contained in:
parent
330a64d820
commit
999a173001
|
@ -118,6 +118,10 @@ class Tags:
|
||||||
return f"artist:{self.artist}/{self.albumartist}, album:{self.album}, title:{self.title}, trackno:{self.tracknumber}"
|
return f"artist:{self.artist}/{self.albumartist}, album:{self.album}, title:{self.title}, trackno:{self.tracknumber}"
|
||||||
|
|
||||||
def union(self, fallback: 'Tags') -> 'Tags':
|
def union(self, fallback: 'Tags') -> 'Tags':
|
||||||
|
"""
|
||||||
|
substitute any tags missing tags in `self` with those from `fallback`.
|
||||||
|
i.e. `self` takes precedence over `fallback`.
|
||||||
|
"""
|
||||||
def merge_field(primary: list[str], secondary: list[str]) -> list[str]:
|
def merge_field(primary: list[str], secondary: list[str]) -> list[str]:
|
||||||
# primary_lower = [i.lower() for i in primary]
|
# primary_lower = [i.lower() for i in primary]
|
||||||
# return primary + [i for i in secondary if i.lower() not in primary_lower]
|
# return primary + [i for i in secondary if i.lower() not in primary_lower]
|
||||||
|
@ -159,6 +163,9 @@ class Tags:
|
||||||
if v.count("/") == 1:
|
if v.count("/") == 1:
|
||||||
trackno, last = v.split("/")
|
trackno, last = v.split("/")
|
||||||
try:
|
try:
|
||||||
|
if int(trackno) == int(last) == 1:
|
||||||
|
# track 1/1: useless; clear the field
|
||||||
|
self.tracknumber[i] = ''
|
||||||
if int(trackno) <= int(last):
|
if int(trackno) <= int(last):
|
||||||
self.tracknumber[i] = trackno.lstrip('0')
|
self.tracknumber[i] = trackno.lstrip('0')
|
||||||
except: pass
|
except: pass
|
||||||
|
@ -401,9 +408,14 @@ class Tagger:
|
||||||
path_tags = Tags.from_path(path_)
|
path_tags = Tags.from_path(path_)
|
||||||
additional_tags = self.manual_tags.union(path_tags)
|
additional_tags = self.manual_tags.union(path_tags)
|
||||||
if self.force:
|
if self.force:
|
||||||
|
# additional_tags overrule old_tags
|
||||||
new_tags = additional_tags.union(old_tags)
|
new_tags = additional_tags.union(old_tags)
|
||||||
else:
|
else:
|
||||||
|
# old_tags overrule additional_tags
|
||||||
new_tags = old_tags.union(additional_tags)
|
new_tags = old_tags.union(additional_tags)
|
||||||
|
if additional_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 = new_tags.union(self.manual_tags)
|
||||||
new_tags.trim_fields()
|
new_tags.trim_fields()
|
||||||
new_tags.cleanup_trackno()
|
new_tags.cleanup_trackno()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user