diff options
Diffstat (limited to 'play.py')
-rwxr-xr-x | play.py | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -1121,15 +1121,17 @@ class PlaylistWindow(TagListWindow): def get_tag(pathname): if re.compile("^http://").match(pathname) or not os.path.exists(pathname): return pathname + tags = {} - # FIXME: use magic instead of file extensions to identify OGGs and MP3s + tagb = "N/A - " + os.path.basename(pathname) + if re.compile(".*\.ogg$", re.I).match(pathname): try: import ogg.vorbis vf = ogg.vorbis.VorbisFile(pathname) vc = vf.comment() tags = vc.as_dict() - except: return os.path.basename(pathname) + except: return tagb elif re.compile(".*\.mp3$", re.I).match(pathname): try: import ID3 @@ -1146,27 +1148,27 @@ def get_tag(pathname): for tag, fid in tagtoframeid.items(): try: index = vc.index(fid) - tags[tag] = (vc[index]['text'],) + tags[tag] = (vc[index]["text"],) except ValueError: - tags[tag] = ("N/A",) + if tag in ["ARTIST", "TITLE"]: tags[tag] = ("",) + else: tags[tag] = ("N/A",) except: pass - except: return os.path.basename(pathname) + except: return tagb else: - return os.path.basename(pathname) + return tagb artist = tags.get("ARTIST", [""])[0] title = tags.get("TITLE", [""])[0] - tag = os.path.basename(pathname) try: import codecs if artist and title: - tag = codecs.latin_1_encode(artist)[0] + " - " + codecs.latin_1_encode(title)[0] + tagb = codecs.latin_1_encode(artist)[0] + " - " + codecs.latin_1_encode(title)[0] elif artist: - tag = artist + tagb = artist elif title: - tag = title - return codecs.latin_1_encode(tag)[0] - except: return tag + tagb = title + return codecs.latin_1_encode(tagb)[0] + except: return tagb # ------------------------------------------ class Player: |