Add more dropped id3v2 tags and short-key translation to mkogg.py.
[blog.git] / posts / mkogg / mkogg.py
index a518ea3b55704814dfc026b1e157aa3b84ab15b5..1c96d0a9e284ff6e0d71fa3c45c2e7e378301ae1 100755 (executable)
@@ -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: