Embed release and year metadata only when available

Follow up of #672.
This commit is contained in:
Ritiek Malhotra
2020-03-02 17:40:30 +05:30
parent 9ecf957c81
commit dc829815f5

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"]: