comparison vixm/song.py @ 30:860c891de6bb master

Remove lots of xmms-related code & get ready to make the whole program a standalone player
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 03 Nov 2006 22:49:09 -0500
parents dfcf1a46fc56
children
comparison
equal deleted inserted replaced
27:e40bdeee5e14 30:860c891de6bb
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as 6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation. 7 # published by the Free Software Foundation.
8 8
9 import xmms 9 import ID3
10 10
11 class song(dict): 11 class song(dict):
12 def __init__(self, pos): 12 def __init__(self, filename, pos):
13 self["file"] = xmms.control.get_playlist_file(pos) 13 id3 = ID3.ID3(filename)
14 self["time"] = xmms.control.get_playlist_time(pos) 14
15 self["file"] = filename
16
17 try:
18 self["album"] = id3["ALBUM"]
19 except KeyError:
20 self["album"] = "unknown"
21
22 try:
23 self["artist"] = id3["ARTIST"]
24 except KeyError:
25 self["artist"] = "unknown"
26
27 try:
28 self["title"] = id3["TITLE"]
29 except KeyError:
30 print "%s doesn't have a title!..using filename" % (filename,)
31 self["title"] = filename
32
33 try:
34 self["year"] = id3["YEAR"]
35 except KeyError:
36 self["year"] = "unknown"
37
38 try:
39 self["genre"] = id3["GENRE"]
40 except KeyError:
41 self["genre"] = "unknown"
42
43 self["time"] = 0
15 self["pos"] = pos 44 self["pos"] = pos
16 self["title"] = xmms.control.get_playlist_title(pos)
17 45
18 def __str__(self): 46 def __str__(self):
19 return self["title"] 47 return "%s - %s" % (self["artist"], self["title"])
48
49 def play(self):
50 # play the actual song
51 pass