annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
1 # song.py - song class
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
2 #
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
3 # Copyright (C) 2006 Josef "Jeff" Sipek <jeffpc@josefsipek.net>
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
4 #
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
5 # This program is free software; you can redistribute it and/or modify
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
6 # it under the terms of the GNU General Public License version 2 as
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
7 # published by the Free Software Foundation.
dfcf1a46fc56 Added GPLv2 file & copyright headers
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 15
diff changeset
8
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
9 import ID3
1
6c5b9827b117 Trivial definition of a song class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
10
6c5b9827b117 Trivial definition of a song class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
11 class song(dict):
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
12 def __init__(self, filename, pos):
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
13 id3 = ID3.ID3(filename)
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
14
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
15 self["file"] = filename
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
16
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
17 try:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
18 self["album"] = id3["ALBUM"]
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
19 except KeyError:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
20 self["album"] = "unknown"
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
21
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
22 try:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
23 self["artist"] = id3["ARTIST"]
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
24 except KeyError:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
25 self["artist"] = "unknown"
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
26
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
27 try:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
28 self["title"] = id3["TITLE"]
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
29 except KeyError:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
30 print "%s doesn't have a title!..using filename" % (filename,)
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
31 self["title"] = filename
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
32
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
33 try:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
34 self["year"] = id3["YEAR"]
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
35 except KeyError:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
36 self["year"] = "unknown"
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
37
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
38 try:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
39 self["genre"] = id3["GENRE"]
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
40 except KeyError:
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
41 self["genre"] = "unknown"
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
42
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
43 self["time"] = 0
1
6c5b9827b117 Trivial definition of a song class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
44 self["pos"] = pos
6c5b9827b117 Trivial definition of a song class
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff changeset
45
15
ae3451bedeb6 Implemented playlist searching
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 1
diff changeset
46 def __str__(self):
30
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
47 return "%s - %s" % (self["artist"], self["title"])
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
48
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
49 def play(self):
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
50 # play the actual song
860c891de6bb Remove lots of xmms-related code & get ready to make the whole program a
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents: 21
diff changeset
51 pass