From 3b444c3b40659c2d6a94b465fd2fbeaecee37452 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Wed, 30 Mar 2011 06:20:45 +0200 Subject: play: use basename only for the title part of the tag --- play.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'play.py') diff --git a/play.py b/play.py index 8f38cda..64b1b6f 100755 --- a/play.py +++ b/play.py @@ -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: -- cgit v1.2.3