* added PlayedTrack.get_timestamp()

This commit is contained in:
Amr Hassan 2009-03-09 14:55:24 +00:00
parent 7c6119ecbc
commit 396d89ee90

View file

@ -554,11 +554,12 @@ class LibraryItem (object):
class PlayedTrack (object): class PlayedTrack (object):
"""A track with a playback date.""" """A track with a playback date."""
def __init__(self, track, date): def __init__(self, track, date, timestamp):
object.__init__(self) object.__init__(self)
self.track = track self.track = track
self.date = date self.date = date
self.timestamp = timestamp
def __repr__(self): def __repr__(self):
return repr(self.track) + " played at " + self.date return repr(self.track) + " played at " + self.date
@ -578,6 +579,11 @@ class PlayedTrack (object):
return self.date return self.date
def get_timestamp(self):
"""Returns the unix timestamp of the playback date."""
return self.timestamp
class Album(_BaseObject, _Taggable): class Album(_BaseObject, _Taggable):
"""A Last.fm album.""" """A Last.fm album."""
@ -2181,11 +2187,12 @@ class User(_BaseObject):
title = _extract(track, "name") title = _extract(track, "name")
artist = _extract(track, "artist") artist = _extract(track, "artist")
date = _extract(track, "date") date = _extract(track, "date")
timestamp = track.getElementsByTagName("date")[0].getAttribute("uts")
if track.hasAttribute('nowplaying'): if track.hasAttribute('nowplaying'):
continue #to prevent the now playing track from sneaking in here continue #to prevent the now playing track from sneaking in here
list.append(PlayedTrack(Track(artist, title, *self.auth_data), date)) list.append(PlayedTrack(Track(artist, title, *self.auth_data), date, timestamp))
return list return list