pythonmp3eyed3

eyed3 add tag release date resolves in error "can't assign to operator"


I try to add the release-date tag to an mp3 file using eyed3 in python. It works fine for the tags "artist" and "date". It is not working for "release-date":

`audiofile.tag.release-date = dateToTag`

throws the error:

SyntaxError: can't assign to operator

This is my setup:

`audiofile = eyed3.load(os.path.join("../mockDirectory", file))
 audiofile.initTag()
 audiofile.tag.artist = u"Artist"
 audiofile.tag.year  = year
 audiofile.tag.release-date = dateToTag`

The value of dateToTag is 2017-10-27, formatted according to the documentation page 30: yyyy-mm-dd. Why is the date format throwing a syntax error?


Solution

  • You get the syntax error because '-' isn't allowed in python identifiers. Python parses is as an operation "audiofile.tag.release (minus) date".

    Try to replace - with an underscore like:

    audiofile.tag.release_date = dateToTag