summaryrefslogtreecommitdiff
path: root/play.py
diff options
context:
space:
mode:
Diffstat (limited to 'play.py')
-rwxr-xr-xplay.py26
1 files changed, 14 insertions, 12 deletions
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: