sane-tag-music: dont abort if metadata fails to load
This commit is contained in:
@@ -45,9 +45,19 @@
|
||||
# - XPAuthor (intended as fallback when Artist is unset)
|
||||
# - XPSubject (i.e. who is in the photo)
|
||||
# - XMP (GIF, PDF, JPEG, PNG): <https://exiftool.org/TagNames/XMP.html>
|
||||
# - XMP:Album
|
||||
# - XMP:Author
|
||||
# - XMP:Producer
|
||||
# - Album
|
||||
# - Author
|
||||
# - Composer
|
||||
# - Director
|
||||
# - DirectorPhotography
|
||||
# - DiscNumber
|
||||
# - Engineer
|
||||
# - Group (?)
|
||||
# - Label
|
||||
# - Producer (Adobe products use this for their own branding)
|
||||
# - ShotNumber
|
||||
# - TapeName
|
||||
# - TrackNumber
|
||||
# mutagen docs:
|
||||
# - <https://mutagen.readthedocs.io/en/latest/>
|
||||
"""
|
||||
@@ -350,6 +360,17 @@ class Tags:
|
||||
if self.albumartist == [ "Various Artists" ] and self.producer == [ "Various Artists" ]:
|
||||
self.producer = []
|
||||
|
||||
producers = []
|
||||
for p in self.producer:
|
||||
if "adobe photoshop" in p.lower():
|
||||
continue
|
||||
if "adobe pdf" in p.lower():
|
||||
continue
|
||||
if "ij scan utility" in p.lower():
|
||||
continue
|
||||
producers.append(p)
|
||||
self.producer = producers
|
||||
|
||||
def rewrite_singles(self) -> None:
|
||||
"""
|
||||
Singles shouldn't generally have a track number: delete it
|
||||
@@ -513,7 +534,13 @@ class MutagenMetadata(MetadataImpl):
|
||||
super().__init__(path_=path_)
|
||||
self.muta = muta
|
||||
|
||||
def new(path_: str, muta) -> 'MutagenMetadata | None':
|
||||
def new(path_: str, opener) -> 'MutagenMetadata | None':
|
||||
muta = None
|
||||
try:
|
||||
muta = opener(path_)
|
||||
except Exception as e:
|
||||
logger.debug(f"failed to open metadata for {path_}: {e!r}")
|
||||
|
||||
if muta is None:
|
||||
return None
|
||||
return MutagenMetadata(path_, muta)
|
||||
@@ -619,19 +646,19 @@ class MediaFile:
|
||||
|
||||
if ext == "aac":
|
||||
# TODO: this seems to only read tags, and not create them?
|
||||
meta = MutagenMetadata.new(f, mutagen.easyid3.EasyID3(f))
|
||||
meta = MutagenMetadata.new(f, mutagen.easyid3.EasyID3)
|
||||
elif ext == "flac":
|
||||
meta = MutagenMetadata.new(f, mutagen.flac.Open(f))
|
||||
meta = MutagenMetadata.new(f, mutagen.flac.Open)
|
||||
elif ext == 'mp3':
|
||||
tag_field_names.producer = "grouping"
|
||||
meta = MutagenMetadata.new(f, mutagen.mp3.EasyMP3(f))
|
||||
meta = MutagenMetadata.new(f, mutagen.mp3.EasyMP3)
|
||||
elif ext in [ 'm4a', 'mp4' ]:
|
||||
tag_field_names.producer = "grouping"
|
||||
meta = MutagenMetadata.new(f, mutagen.easymp4.EasyMP4(f))
|
||||
meta = MutagenMetadata.new(f, mutagen.easymp4.EasyMP4)
|
||||
elif ext in 'ogg':
|
||||
meta = MutagenMetadata.new(f, mutagen.oggvorbis.OggVorbis(f))
|
||||
meta = MutagenMetadata.new(f, mutagen.oggvorbis.OggVorbis)
|
||||
elif ext == 'opus':
|
||||
meta = MutagenMetadata.new(f, mutagen.oggopus.OggOpus(f))
|
||||
meta = MutagenMetadata.new(f, mutagen.oggopus.OggOpus)
|
||||
elif ext == "gif":
|
||||
tag_field_names.album = "XMP:Album"
|
||||
tag_field_names.albumartist = "XMP:Author"
|
||||
|
Reference in New Issue
Block a user