summaryrefslogtreecommitdiff
path: root/play.py
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2011-03-30 02:01:42 (GMT)
committerAdrian C. (anrxc) <anrxc@sysphere.org>2011-03-30 02:01:42 (GMT)
commit57cd50ead63b7bda9d03b08139e7ac63557d8700 (patch)
tree6efb1a32121d1b726c18bd62b8f520f12e0c2163 /play.py
parenta29a8a9243e01d3fca67c4b3eb3dfb3ecdeb71e7 (diff)
downloadplay-57cd50ead63b7bda9d03b08139e7ac63557d8700.tar.xz
play: add pyid3lib support as alternative for MP3 tags
Diffstat (limited to 'play.py')
-rwxr-xr-xplay.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/play.py b/play.py
index 107c525..8f38cda 100755
--- a/play.py
+++ b/play.py
@@ -1135,6 +1135,21 @@ def get_tag(pathname):
import ID3
vc = ID3.ID3(pathname, as_tuple=1)
tags = vc.as_dict()
+ except ImportError:
+ try:
+ from pyid3lib import tag as ID3
+ vc = ID3(pathname)
+ tagtoframeid = {
+ 'ALBUM' : 'TALB', 'ARTIST' : 'TPE1', 'TITLE' : 'TIT2',
+ 'YEAR' : 'TYER', 'GENRE' : 'TCON', 'TRACKNUMBER' : 'TRCK'
+ }
+ for tag, fid in tagtoframeid.items():
+ try:
+ index = vc.index(fid)
+ tags[tag] = (vc[index]['text'],)
+ except ValueError:
+ tags[tag] = ("N/A",)
+ except: pass
except: return os.path.basename(pathname)
else:
return os.path.basename(pathname)