Top

spotify.v1.artist.album module

from spotify import values
from spotify.page import Page
from spotify.resource import Resource


class AlbumList(Resource):

    def __init__(self, version, artist_id):
        super(AlbumList, self).__init__(version)
        self.artist_id = artist_id

    def list(self, album_type=values.UNSET, market=values.UNSET, limit=values.UNSET, offset=values.UNSET):
        params = values.of({
            'album_type': album_type,
            'market': market,
            'limit': limit,
            'offset': offset
        })
        response = self.version.request('GET', '/artist/{}/albums'.format(self.artist_id), params=params)
        return AlbumPage(self.version, response.json(), 'items')


class AlbumPage(Page):

    @property
    def instance_class(self):
        from spotify.v1.album import AlbumInstance
        return AlbumInstance

Classes

class AlbumList

class AlbumList(Resource):

    def __init__(self, version, artist_id):
        super(AlbumList, self).__init__(version)
        self.artist_id = artist_id

    def list(self, album_type=values.UNSET, market=values.UNSET, limit=values.UNSET, offset=values.UNSET):
        params = values.of({
            'album_type': album_type,
            'market': market,
            'limit': limit,
            'offset': offset
        })
        response = self.version.request('GET', '/artist/{}/albums'.format(self.artist_id), params=params)
        return AlbumPage(self.version, response.json(), 'items')

Ancestors (in MRO)

  • AlbumList
  • spotify.resource.Resource
  • __builtin__.object

Instance variables

var artist_id

Methods

def __init__(

self, version, artist_id)

def __init__(self, version, artist_id):
    super(AlbumList, self).__init__(version)
    self.artist_id = artist_id

def list(

self, album_type='UNSET', market='UNSET', limit='UNSET', offset='UNSET')

def list(self, album_type=values.UNSET, market=values.UNSET, limit=values.UNSET, offset=values.UNSET):
    params = values.of({
        'album_type': album_type,
        'market': market,
        'limit': limit,
        'offset': offset
    })
    response = self.version.request('GET', '/artist/{}/albums'.format(self.artist_id), params=params)
    return AlbumPage(self.version, response.json(), 'items')

class AlbumPage

class AlbumPage(Page):

    @property
    def instance_class(self):
        from spotify.v1.album import AlbumInstance
        return AlbumInstance

Ancestors (in MRO)

  • AlbumPage
  • 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
    )