python-lastfm/src/playlist.py

49 lines
1.3 KiB
Python
Raw Normal View History

2008-07-10 22:25:05 +05:30
#!/usr/bin/env python
__author__ = "Abhinav Sarkar <abhinav@abhinavsarkar.net>"
2008-07-10 22:25:05 +05:30
__version__ = "0.1"
__license__ = "GNU Lesser General Public License"
2008-07-15 00:38:39 +05:30
from base import LastfmBase
class Playlist(LastfmBase):
2008-07-10 22:25:05 +05:30
"""A class representing an XPSF playlist."""
def init(self, xpsfData, url):
self.__data = xpsfData
self.__url = url
2008-07-15 00:38:39 +05:30
@property
def data(self):
"""playlist's data"""
return self.__data
@property
def url(self):
"""url of the playlist"""
return self.__url
2008-07-10 22:25:05 +05:30
@staticmethod
def fetch(api, url):
params = {'method': 'playlist.fetch', 'playlistURL': url}
2008-07-25 16:29:48 +05:30
return Playlist(api._fetchData(params, parse = False), url = url)
2008-07-15 00:38:39 +05:30
@staticmethod
def hashFunc(*args, **kwds):
try:
return hash(kwds['url'])
2008-07-15 00:38:39 +05:30
except KeyError:
raise LastfmInvalidParametersError("url has to be provided for hashing")
2008-07-15 00:38:39 +05:30
def __hash__(self):
return self.__class__.hashFunc(url = self.url)
2008-07-15 00:38:39 +05:30
def __eq__(self, other):
return self.url == other.url
2008-07-15 00:38:39 +05:30
def __lt__(self, other):
return self.url < other.url
2008-07-15 00:38:39 +05:30
def __repr__(self):
return "<lastfm.Playlist: %s>" % self.url
2008-07-15 17:29:49 +05:30
from error import LastfmInvalidParametersError