sane-tag-music: fix ImageFile to actually support tag deletion
This commit is contained in:
@@ -511,6 +511,7 @@ class AudioFile(MediaFile):
|
||||
|
||||
class ImageFile(MediaFile):
|
||||
_exiftool = None # static, lazy init
|
||||
TAG_PREFIXES = ("", "EXIF:", "PNG:", "XMP:")
|
||||
|
||||
def __init__(self, path_: str):
|
||||
super().__init__(path_)
|
||||
@@ -536,10 +537,8 @@ class ImageFile(MediaFile):
|
||||
acc += [t for t in new if t not in acc]
|
||||
def get_tag(name: str) -> list:
|
||||
acc = []
|
||||
append_tags(acc, get_tag_(name))
|
||||
append_tags(acc, get_tag_(f"EXIF:{name}"))
|
||||
append_tags(acc, get_tag_(f"PNG:{name}"))
|
||||
append_tags(acc, get_tag_(f"XMP:{name}"))
|
||||
for prefix in self.TAG_PREFIXES:
|
||||
append_tags(acc, get_tag_(f"{prefix}{name}"))
|
||||
return acc
|
||||
|
||||
return Tags(
|
||||
@@ -560,8 +559,12 @@ class ImageFile(MediaFile):
|
||||
if len(val) == 1:
|
||||
self.exif[name] = val[0]
|
||||
elif len(val) == 0:
|
||||
if name in self.exif:
|
||||
del self.exif[name]
|
||||
# tags are deleted by setting them "",
|
||||
# and we have to clear all possible tag variants else the deleted one will be re-derived from the others next read.
|
||||
for prefix in self.TAG_PREFIXES:
|
||||
pname = f"{prefix}{name}"
|
||||
if pname in self.exif:
|
||||
self.exif[pname] = ""
|
||||
else:
|
||||
logger.warning(f"multiple values for tag {name}: {val!r}")
|
||||
|
||||
|
Reference in New Issue
Block a user