def degenrefy(file_path): id3 = get_mutagen_id3(file_path) try: del(id3['TCON']) except: pass id3.save()
def demojibake(file_path, wrong, right, commit=True): id3 = get_mutagen_id3(file_path) for encoding in (wrong, right): # Throws a LookupError, must be handled in calling code codecs.lookup(encoding) results = {} for frame in id3.itervalues(): if frame.FrameID not in mojibaked_frames.keys(): continue results[frame.FrameID] = [] results[frame.FrameID].append(frame.text[0]) try: frame.text[0] = frame.text[0].encode(wrong).decode(right) frame.encoding = 3 results[frame.FrameID].append(frame.text[0]) except: pass if commit: id3.save() return results
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "dminkovsky" import argparse import os.path import sys from utils import get_mutagen_id3 if __name__ == "__main__": argparser = argparse.ArgumentParser() argparser.add_argument("target", help="file from which to dump tag data") args = argparser.parse_args() file_path = os.path.abspath(args.target) try: print "ID3 tag data in `{}`:\n".format(file_path) id3 = get_mutagen_id3(file_path) print id3.pprint() + "\n" sys.exit(0) except IOError: print "Fatal Error: Cannot open {}.".format(file_path) sys.exit(255)