#!/usr/bin/env pythonfrom tagger import *import sys# fix tags in a single filedef unjamendo(f): tags = id3v2.ID3v2(f) for frame in tags.frames: # I check tag encoding as fool protection - since i'll write all tags in utf_8 # I should only encounter utf_16 in corrupt files if frame.encoding == "utf_16" and len(frame.strings)>0: # so here is the actual solution: # I decode from utf_16 to utf_8 using .encode("latin_1") because that's what went wrong # I then 'decode' utf_8 to python unicode object # yes i know this doesn't sound right, but that's the problem with them tags frame.strings = [s.encode("latin_1").decode("utf_8") for s in frame.strings] frame.encoding = "utf_8" tags.commit() # fix tags in all files given on command line# i run it from bash like:## python unj.py *jamendo*/*.mp3## using the fact that all albums from jamendo have 'jamendo' in directory namefor f in sys.argv[1:]: unjamendo(f)