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 --- README | 14 +++++++------- play.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/README b/README index f4d2d77..27fbcd6 100644 --- a/README +++ b/README @@ -15,9 +15,11 @@ Usage: Miscellaneous: In order for either mp3info (ID3) or ogginfo to work, both - corresponding python modules have to be installed. However, - quick support for MP3 tags can be added by getting 'ID3.py' - from the id3-py project: http://id3-py.sourceforge.net/ + corresponding python modules have to be installed. Quickest + support for MP3 tags can be added by getting 'ID3.py' from the + id3-py project: http://id3-py.sourceforge.net or by installing + the (much more popular) 'pyid3lib' package provided by your OS + distribution. A playlist can contain URLs, but the playlist itself will have to be local. For mpeg streaming splay is recommended. @@ -34,7 +36,5 @@ Authors: forked. This exceptional software, originally written by Ulf Betlehem, should not be forgotten. - In March of 2011 a cplay branch was found on GitHub, published - by Tomi Pievilainen, with some interesting patches on top of - the original cplay. Very much like play includes. From this - code MPlayer support was added to play. + MPlayer support was added to play from the excellent work done + by Tom Adams and Tomi Pievilainen on GitHub.com. 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