From: W. Trevor King Date: Mon, 5 Dec 2011 14:22:01 +0000 (-0500) Subject: Add more dropped id3v2 tags and short-key translation to mkogg.py. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c7008c6239f3e1c592da6b43e949d1ae49c1f40d;p=blog.git Add more dropped id3v2 tags and short-key translation to mkogg.py. The occurence of three-charachter short tag keys may be due to the version 0.1.11 -> 0.1.12 transition in the id3v2 utility. In any case, the new translation dictionary makes it easy to map new keys onto already existing synonyms. Also, we no longer attempt to parse the 'no id3v1 tag' message as if it were another tag. --- diff --git a/posts/mkogg/mkogg.py b/posts/mkogg/mkogg.py index a518ea3..1c96d0a 100755 --- a/posts/mkogg/mkogg.py +++ b/posts/mkogg/mkogg.py @@ -268,6 +268,8 @@ class Converter (object): 'ncon', # ? 'pcnt', # play counter (incremented with each play) 'priv', # private + 'tco', # content type + 'tcp', # frame? 'tenc', # encoded by 'tflt', # file type 'tope', # original artist (e.g. for a cover) @@ -275,6 +277,16 @@ class Converter (object): 'tmed', # media type 'wxxx', # user defined URL ] + key_translations = { + 'com': 'comm', + 'ten': 'tenc', + 'tal': 'talb', + 'tcm': 'tcom', + 'tt2': 'tit2', + 'tp1': 'tpe1', + 'trk': 'trck', + 'tye': 'tyer', + } in_v2 = False for line in stdout.splitlines(): if not in_v2: @@ -282,10 +294,13 @@ class Converter (object): in_v2 = True continue key,value = [x.strip() for x in line.split(':', 1)] - short_key = key.split()[0] - if short_key.lower() in drop_keys: + if value.lower() == 'no id3v1 tag': + continue + short_key = key.split()[0].lower() + short_key = key_translations.get(short_key, short_key) + if short_key in drop_keys: continue - v_key = vorbis_keys[short_key.lower()] + v_key = vorbis_keys[short_key] if v_key == 'genre': value = value.rsplit('(', 1)[0].strip() elif v_key == 'tracknumber' and '/' in value: