Last active
July 15, 2017 19:20
-
-
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
This file contains 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
#!/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