view vixm/ @ 46:2d570448aba5 pure

Abstract out the stats code a little bit more This is in preparation for moving the stats code completely out of player code
author Josef "Jeff" Sipek <>
date Mon, 06 Nov 2006 05:19:23 -0500
parents 860c891de6bb
line wrap: on
line source

# - song class
# Copyright (C) 2006  Josef "Jeff" Sipek <>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

import ID3

class song(dict):
	def __init__(self, filename, pos):
		id3 = ID3.ID3(filename)

		self["file"]	= filename

			self["album"]	= id3["ALBUM"]
		except KeyError:
			self["album"]	= "unknown"

			self["artist"]	= id3["ARTIST"]
		except KeyError:
			self["artist"]	= "unknown"

			self["title"]	= id3["TITLE"]
		except KeyError:
			print "%s doesn't have a title!..using filename" % (filename,)
			self["title"]	= filename

			self["year"]	= id3["YEAR"]
		except KeyError:
			self["year"]	= "unknown"

			self["genre"]	= id3["GENRE"]
		except KeyError:
			self["genre"]	= "unknown"

		self["time"]	= 0
		self["pos"]	= pos

	def __str__(self):
		return "%s - %s" % (self["artist"], self["title"])

	def play(self):
		# play the actual song