Created
November 8, 2013 15:42
-
-
Save acgotaku/7372856 to your computer and use it in GitHub Desktop.
convert apev2tag to id3v2 version 2.4dependencies:matag
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 python2 | |
# convert apev2 tag to id3 v2.4 tag | |
import os | |
import sys | |
import locale | |
from optparse import OptionParser | |
import mutagen.id3 | |
import mutagen.apev2 | |
def main(argv): | |
from mutagen import File | |
args = argv[1:] | |
for filename in args: | |
try: | |
tag = mutagen.apev2.APEv2(filename) | |
except: | |
print filename+"File doesn't have an APEv2 tag" | |
return | |
track=str(tag.__getitem__("Track")) | |
album=str(tag.__getitem__("Album")).decode('utf8') | |
title=str(tag.__getitem__("Title")).decode('utf8') | |
artist=str(tag.__getitem__("Artist")).decode('utf8') | |
frames = {} | |
frames["TRCK"] = mutagen.id3.TRCK(encoding=3, text=track) | |
frames["TALB"] = mutagen.id3.TALB(encoding=3, text=album) | |
frames["TIT2"] = mutagen.id3.TIT2(encoding=3, text=title) | |
frames["TPE1"] = mutagen.id3.TPE1(encoding=3, text=artist) | |
test=mutagen.id3.TPE1(encoding=3, text=artist) | |
fileID3 = mutagen.id3.ID3() | |
for frame in frames.values(): | |
fileID3.add(frame) | |
fileID3.save(filename) | |
mutagen.apev2.delete(filename) | |
mutagen.id3.delete(filename, True,False) | |
if __name__ == "__main__": | |
try: import mutagen | |
except ImportError: | |
sys.path.append(os.path.abspath("../")) | |
import mutagen | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment