From 57cd50ead63b7bda9d03b08139e7ac63557d8700 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Wed, 30 Mar 2011 04:01:42 +0200 Subject: play: add pyid3lib support as alternative for MP3 tags --- play.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'play.py') 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) -- cgit v1.2.3