ocarina/libsaria/sources/library/track.py
Bryan Schumaker b1d8ba7653 libsaria: Remove old ids from library
If the song was deleted it should be removed.

This patch also addse in the Track() class that should have been in the
last patch.
2011-05-21 08:01:13 -04:00

29 lines
679 B
Python

# Bryan Schumaker (5 / 21 / 2011)
import tagpy
import datetime
FileRef = tagpy.FileRef
timedelta = datetime.timedelta
class Track:
def __init__(self, filepath):
ref = FileRef(filepath)
tags = ref.tag()
audio = ref.audioProperties()
self.artist = tags.artist or u"Unknown Artist"
self.album = tags.album or u"Unknown Album"
self.title = tags.title or u"Unknown Title"
self.track = tags.track
self.genre = tags.genre
self.year = tags.year
self.seconds = audio.length
self.filepath = filepath
lenstr = "%s" % timedelta(seconds=self.seconds)
if lenstr[:2] == "0:":
self.lenstr = lenstr[2:]
else:
self.lenstr = lenstr