Closed phantom2152 closed 3 years ago
@phantom2152 Hi! because you should use EasyID3
class for that. And EasyID3
class has no year
key but he has date
key for that.
I give you correct example:
from mutagen.easyid3 import EasyID3
mp3_file = r"D:\tmp\tmp_mp3\Track 09.mp3"
try:
id3_easy = EasyID3(mp3_file)
except mutagen.id3.ID3NoHeaderError:
# mp3 file might has no ID3 tags at all
id3_easy = EasyID3()
id3_easy["date"] = "2021"
id3_easy.save(mp3_file, v2_version=3, v1=2)
If you want to edit (set) another tags using EasyID3
you can print all available tags for this class:
>>> from mutagen.easyid3 import EasyID3
>>> print(EasyID3.valid_keys.keys())
>>> dict_keys(['album', 'bpm', 'compilation', 'composer', 'copyright', 'encodedby', 'lyricist', 'length', 'media', 'mood', 'title', 'version', 'artist', 'albumartist', 'conductor', 'arranger', 'discnumber', 'organization', 'tracknumber', 'author', 'albumartistsort', 'albumsort', 'composersort', 'artistsort', 'titlesort', 'isrc', 'discsubtitle', 'language', 'genre', 'date', 'originaldate', 'performer:*', 'musicbrainz_trackid', 'website', 'replaygain_*_gain',
'replaygain_*_peak', 'musicbrainz_artistid', 'musicbrainz_albumid', 'musicbrainz_albumartistid', 'musicbrainz_trmid', 'musicip_puid', 'musicip_fingerprint', 'musicbrainz_albumstatus', 'musicbrainz_albumtype', 'releasecountry', 'musicbrainz_discid', 'asin', 'performer', 'barcode', 'catalognumber', 'musicbrainz_releasetrackid', 'musicbrainz_releasegroupid', 'musicbrainz_workid', 'acoustid_fingerprint', 'acoustid_id'])
Hey thank you ,I used a different approach
I manually register a new key to EasyID3
EasyID3.RegisterTextKey("year", "TDRC")
Hey I am using the EasyMP3 to add metadata to an mp3 file but when I try to add year its saying year is not a valid key , can anyone give me some information on adding year tag?