title: How to set: "artist", "album artist", "year", "album", "song number" and "title" fields of the tag, with mutagen
body: <p>I'm trying to use mutagen (with Python 2.7.5) to create a program that, given that the path to songs is <code>...\Artist\Year Album\Songnumber Title.mp3</code>, sets the artist, album artist, year, album, song number and title tags of the song, and preserves the genre tag. I tried to do this with <a href="https://mutagen.readthedocs.io/en/latest/api/id3.html#module-mutagen.easyid3" rel="nofollow noreferrer">EasyID3</a>, but it doesn't have the album artist tag. I also tried to do it with regular <a href="https://mutagen.readthedocs.io/en/latest/api/id3.html#id1" rel="nofollow noreferrer">ID3</a>, but I ran into a couple of problems with it. Here's the code I used:</p>
  
  <pre><code>from mutagen.id3 import ID3, TIT2, TPE2, TALB, TPE1, TYER, TDAT, TRCK, TCON, TORY, TPUB
  p = "E:\\Musik\\Aeon\\2005 Bleeding the False\\01 Cenobites - Copy.mp3"
  audio = ID3(p)
  audio.add(TIT2(encoding=3, text=u"t"))    #TITLE
  audio.add(TRCK(encoding=3, text=u"1"))    #TRACK
  audio.add(TPE1(encoding=3, text=u"a"))    #ARTIST
  audio.add(TALB(encoding=3, text=u"al"))   #ALBUM
  audio.add(TYER(encoding=3, text=u"2000")) #YEAR
  audio.add(TDAT(encoding=3, text=u"2001")) #YEAR
  audio.add(TORY(encoding=3, text=u"2002")) #ORIGYEAR
  audio.add(TPE2(encoding=3, text=u"aa"))   #ALBUMARTIST
  audio.add(TCON(encoding=3, text=u"g"))    #GENRE
  audio.save()
  </code></pre>
  
  <p>I used <a href="http://help.mp3tag.de/main_tags.html" rel="nofollow noreferrer">this table</a> to find the 4-letter codes for each tag.</p>
  
  <p>Title, track, artist and album all worked fine. For all fields under the mp3 file's properties>details except these four and "year", previous values were cleared by <code>save()</code>, and when I tried to add new ones, nothing happened. In particular the "genre" and "album artist" fields didn't work. As for "year" which has both the codes TYER and TDAT, it wouldn't change at all unless the field was empty first, and then only by TYER. "ORIGYEAR" with the code TORY did nothing.</p>
  
  <p>The "genre" field isn't actually completely broken - if you change it with python code (<code>audio.add(etc)</code>), or manually go into properties>details beforehand, <code>save()</code> will clear non-built-in genres such as "Technical Death Metal" or "mt3jr39kf390", while it works with built-in genres such as "Classic Rock" or "Country", while certain integers such as 1 or 2 turn into those built-in genres. (The year field occasionally behaves similarly as well - if you manually set the field value to certain numbers, <code>save()</code> will change it into a different number. I've only observed this for values below 800, but not for all - 448 and 449 remain unchanged, while 500 turns into 320, 700 turns into 448, 12 turns into 10, and 10 turns into 8. If you change 12 to 10 this way and then run the program again, nothing will happen, but if you manually change it to some other value and back to 10, it will turn into 8.)</p>
  
  <p>So, the problem is that I can't change the year tag if there's already something there, I can't change the album artist or genre tag, and I don't know how to do the "get" command if there even is one so I can preserve the genre tag.</p>
  
  <p>Also, <a href="https://mutagen.readthedocs.io/en/latest/api/id3.html#module-mutagen.easyid3" rel="nofollow noreferrer">EasyID3</a> has the same issues — <code>save()</code> clears certain fields and behaves weirdly with genre and year. The only difference seems to be that it's possible to change the year even if the field isn't empty. Here's the code I used:</p>
  
  <pre><code>from mutagen.easyid3 import EasyID3
  p = "E:\\Musik\\Aeon\\2005 Bleeding the False\\01 Cenobites - Copy.mp3"
  audio = EasyID3(p)
  audio["title"] = u"t"
  audio["artist"] = u"a"
  audio["album"] = "al"
  audio["date"] = u"2000"
  audio["tracknumber"] = u"1"
  audio["genre"] = u"g"
  audio.save()
  print '\n'.join(EasyID3.valid_keys.keys())
  </code></pre>