Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
Created October 4, 2011 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jehoshua02/1261206 to your computer and use it in GitHub Desktop.
Save jehoshua02/1261206 to your computer and use it in GitHub Desktop.
mutagen: mp3 tags in not showing in windows explorer
from shutil import copyfile
from mutagen.mp3 import MP3
from mutagen.id3 import ID3, TIT2, TCON, TALB
def resetFile():
"""Copies original.mp3 to somefile.mp3 and returns an mutagen MP3 file handle"""
filename = 'somefile.mp3'
copyfile('original.mp3', filename)
file = MP3(filename)
return file
def showStuff(file, keys=['TIT2', 'TCON', 'TALB']):
"""Prints out specified id3 tags for a file"""
for key in keys:
print '%s: %s' % (key, file[key])
def saveFile(file):
"""Save the file"""
# I'm having problems here.
# Even without changing any tags, this causes
# information in Windows Explorer to disappear.
# However, I was able to see all the information
# in WINAMP Media Player. So perhaps this is just
# another case of Microsloth Winblows failing to
# conform to standards? Both WINAMP and mutagen are
# able to see the changes.
file.save()
def setTitle(file, title):
"""Change the title"""
file['TIT2'] = TIT2(0, title)
file = resetFile()
showStuff(file)
saveFile(file)
showStuff(file)
@trulycool
Copy link

Windows Explorer implements an older version of the ID3 tags; you can use:
file.save(v2_version=3)
...with your code above, and the tags will show in Explorer on Windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment