view vixm/song.py @ 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 <jeffpc@josefsipek.net>
date Mon, 06 Nov 2006 05:19:23 -0500
parents 860c891de6bb
children
line wrap: on
line source

# song.py - song class
#
# Copyright (C) 2006  Josef "Jeff" Sipek <jeffpc@josefsipek.net>
#
# 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

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

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

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

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

		try:
			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
		pass