Skip to content

Instantly share code, notes, and snippets.

@rwanyoike
Last active July 15, 2017 19:20
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 rwanyoike/4329422c3e098e55ef86 to your computer and use it in GitHub Desktop.
Save rwanyoike/4329422c3e098e55ef86 to your computer and use it in GitHub Desktop.
Correct Shift JIS encoded MP3s, and convert them to ID3 v2.4 while at it
#!/usr/bin/env python
import glob
import logging
import eyed3
def moolala(tag):
try:
return tag.encode("latin1").decode("shiftjis")
except UnicodeEncodeError:
return None
def magix():
for f in glob.glob("**/*.mp3"):
mp3 = eyed3.load(f)
title = moolala(mp3.tag.title)
if title:
mp3.tag.title = title
artist = moolala(mp3.tag.artist)
if artist:
mp3.tag.artist = artist
mp3.tag.save(version=eyed3.id3.ID3_V2_4, encoding='utf8')
if title or artist:
print "Updated: {}".format(mp3.tag.file_info.name)
print ""
if __name__ == "__main__":
magix()
print "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment