Merge pull request #674 from ritiek/fix-mutagen-crash

Fix mutagen crash
This commit is contained in:
Ritiek Malhotra
2020-03-02 17:44:14 +05:30
committed by GitHub
2 changed files with 12 additions and 6 deletions

View File

@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Fixed
Embed release date metadata only when available (follow up of #672) ([@ritiek](https://github.com/ritiek)) (#674)
## [1.2.5] - 2020-03-02 ## [1.2.5] - 2020-03-02
### Fixed ### Fixed

View File

@@ -76,6 +76,7 @@ class EmbedMetadata:
# https://github.com/quodlibet/mutagen/blob/master/mutagen/id3/_frames.py # https://github.com/quodlibet/mutagen/blob/master/mutagen/id3/_frames.py
# Each class represents an id3 tag # Each class represents an id3 tag
audiofile = ID3(music_file) audiofile = ID3(music_file)
if meta_tags["year"]:
audiofile["TORY"] = TORY(encoding=3, text=meta_tags["year"]) audiofile["TORY"] = TORY(encoding=3, text=meta_tags["year"])
audiofile["TYER"] = TYER(encoding=3, text=meta_tags["year"]) audiofile["TYER"] = TYER(encoding=3, text=meta_tags["year"])
if meta_tags["publisher"]: if meta_tags["publisher"]:
@@ -109,6 +110,7 @@ class EmbedMetadata:
meta_tags = self.meta_tags meta_tags = self.meta_tags
audiofile = MP4(music_file) audiofile = MP4(music_file)
self._embed_basic_metadata(audiofile, preset=M4A_TAG_PRESET) self._embed_basic_metadata(audiofile, preset=M4A_TAG_PRESET)
if meta_tags["year"]:
audiofile[M4A_TAG_PRESET["year"]] = meta_tags["year"] audiofile[M4A_TAG_PRESET["year"]] = meta_tags["year"]
audiofile[M4A_TAG_PRESET["comment"]] = meta_tags["external_urls"][self.provider] audiofile[M4A_TAG_PRESET["comment"]] = meta_tags["external_urls"][self.provider]
if meta_tags["lyrics"]: if meta_tags["lyrics"]:
@@ -130,6 +132,7 @@ class EmbedMetadata:
meta_tags = self.meta_tags meta_tags = self.meta_tags
audiofile = FLAC(music_file) audiofile = FLAC(music_file)
self._embed_basic_metadata(audiofile) self._embed_basic_metadata(audiofile)
if meta_tags["year"]:
audiofile["year"] = meta_tags["year"] audiofile["year"] = meta_tags["year"]
audiofile["comment"] = meta_tags["external_urls"][self.provider] audiofile["comment"] = meta_tags["external_urls"][self.provider]
if meta_tags["lyrics"]: if meta_tags["lyrics"]:
@@ -155,6 +158,7 @@ class EmbedMetadata:
if meta_tags["album"]["name"]: if meta_tags["album"]["name"]:
audiofile[preset["album"]] = meta_tags["album"]["name"] audiofile[preset["album"]] = meta_tags["album"]["name"]
audiofile[preset["title"]] = meta_tags["name"] audiofile[preset["title"]] = meta_tags["name"]
if meta_tags["release_date"]:
audiofile[preset["date"]] = meta_tags["release_date"] audiofile[preset["date"]] = meta_tags["release_date"]
audiofile[preset["originaldate"]] = meta_tags["release_date"] audiofile[preset["originaldate"]] = meta_tags["release_date"]
if meta_tags["genre"]: if meta_tags["genre"]: