spotify.v1.artist.top_track module
from spotify.page import Page
from spotify.resource import Resource
class TopTrackList(Resource):
def __init__(self, version, artist_id):
super(TopTrackList, self).__init__(version)
self.artist_id = artist_id
def list(self, country):
params = {
'country': country
}
response = self.version.request('GET', '/artists/{}/top-tracks'.format(self.artist_id), params=params)
return TopTrackPage(self.version, response.json(), 'tracks')
class TopTrackPage(Page):
@property
def instance_class(self):
from spotify.v1.track import TrackInstance
return TrackInstance
Classes
class TopTrackList
class TopTrackList(Resource):
def __init__(self, version, artist_id):
super(TopTrackList, self).__init__(version)
self.artist_id = artist_id
def list(self, country):
params = {
'country': country
}
response = self.version.request('GET', '/artists/{}/top-tracks'.format(self.artist_id), params=params)
return TopTrackPage(self.version, response.json(), 'tracks')
Ancestors (in MRO)
- TopTrackList
- spotify.resource.Resource
- __builtin__.object
Instance variables
var artist_id
Methods
def __init__(
self, version, artist_id)
def __init__(self, version, artist_id):
super(TopTrackList, self).__init__(version)
self.artist_id = artist_id
def list(
self, country)
def list(self, country):
params = {
'country': country
}
response = self.version.request('GET', '/artists/{}/top-tracks'.format(self.artist_id), params=params)
return TopTrackPage(self.version, response.json(), 'tracks')
class TopTrackPage
class TopTrackPage(Page):
@property
def instance_class(self):
from spotify.v1.track import TrackInstance
return TrackInstance
Ancestors (in MRO)
- TopTrackPage
- spotify.page.Page
- spotify.resource.Resource
- __builtin__.object
Instance variables
var instance_class
Methods
def __init__(
self, version, data, key)
def __init__(self, version, data, key):
super(Page, self).__init__(version)
self._key = key
self._items = iter([self.instance_class(self.version, item) for item in data.get(key, [])])
del data[key]
self._meta = data
def has_next_page(
self)
def has_next_page(self):
return 'next' in self._meta and self._meta['next'] is not None
def next_page(
self)
def next_page(self):
response = self.version.request(self._meta['next'])
return self.__class__(
self.version,
response.json(),
self._key
)