summaryrefslogtreecommitdiff
path: root/play.py
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2011-03-30 04:20:45 (GMT)
committerAdrian C. (anrxc) <anrxc@sysphere.org>2011-03-30 04:20:45 (GMT)
commit3b444c3b40659c2d6a94b465fd2fbeaecee37452 (patch)
treeaa31d7942b1853c05a81caf856ef85007087715a /play.py
parent57cd50ead63b7bda9d03b08139e7ac63557d8700 (diff)
downloadplay-3b444c3b40659c2d6a94b465fd2fbeaecee37452.tar.xz
play: use basename only for the title part of the tag
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: