Created
October 4, 2011 09:11
-
-
Save jehoshua02/1261206 to your computer and use it in GitHub Desktop.
mutagen: mp3 tags in not showing in windows explorer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.