Esempio n. 1
0
 def get_image(sp_artistbrowse, key):
     image_id = lib.sp_artistbrowse_portrait(sp_artistbrowse, key)
     sp_image = lib.sp_image_create(image_id)
     return spotify.Image(self._session,
                          sp_image=sp_image,
                          add_ref=False,
                          callback=callback)
Esempio n. 2
0
 def image_changed(sp_playlist, image_id, userdata):
     logger.debug('Playlist image changed')
     playlist = Playlist._cached(
         spotify._session_instance, sp_playlist, add_ref=True)
     sp_image = lib.sp_image_create(
         spotify._session_instance._sp_session, image_id)
     image = spotify.Image(
         spotify._session_instance, sp_image=sp_image, add_ref=False)
     playlist.emit(PlaylistEvent.IMAGE_CHANGED, playlist, image)
Esempio n. 3
0
    def cover(self, image_size=None):
        """The album's cover :class:`Image`.

        ``image_size`` is an :class:`ImageSize` value, by default
        :attr:`ImageSize.NORMAL`.

        Will always return :class:`None` if the album isn't loaded or the
        album has no cover.
        """
        if image_size is None:
            image_size = spotify.ImageSize.NORMAL
        cover_id = lib.sp_album_cover(self._sp_album, image_size)
        if cover_id == ffi.NULL:
            return None
        sp_image = lib.sp_image_create(
            spotify.session_instance._sp_session, cover_id)
        return spotify.Image(sp_image=sp_image, add_ref=False)
Esempio n. 4
0
    def portrait(self, image_size=None):
        """The artist's portrait :class:`Image`.

        ``image_size`` is an :class:`ImageSize` value, by default
        :attr:`ImageSize.NORMAL`.

        Will always return :class:`None` if the artist isn't loaded or the
        artist has no portrait.
        """
        if image_size is None:
            image_size = spotify.ImageSize.NORMAL
        portrait_id = lib.sp_artist_portrait(self._sp_artist, image_size)
        if portrait_id == ffi.NULL:
            return None
        sp_image = lib.sp_image_create(spotify.session_instance._sp_session,
                                       portrait_id)
        return spotify.Image(sp_image=sp_image, add_ref=False)
Esempio n. 5
0
    def image(self, callback=None):
        """The playlist's :class:`Image`.

        Due to limitations in libspotify's API you can't specify the
        :class:`ImageSize` of these images.

        If ``callback`` isn't :class:`None`, it is expected to be a callable
        that accepts a single argument, an :class:`Image` instance, when
        the image is done loading.

        Will always return :class:`None` if the playlist isn't loaded or the
        playlist has no image.
        """
        image_id = ffi.new('char[20]')
        has_image = bool(
            lib.sp_playlist_get_image(self._sp_playlist, image_id))
        if not has_image:
            return None
        sp_image = lib.sp_image_create(self._session._sp_session, image_id)
        return spotify.Image(
            self._session, sp_image=sp_image, add_ref=False, callback=callback)
Esempio n. 6
0
    def cover(self, image_size=None, callback=None):
        """The album's cover :class:`Image`.

        ``image_size`` is an :class:`ImageSize` value, by default
        :attr:`ImageSize.NORMAL`.

        If ``callback`` isn't :class:`None`, it is expected to be a callable
        that accepts a single argument, an :class:`Image` instance, when
        the image is done loading.

        Will always return :class:`None` if the album isn't loaded or the
        album has no cover.
        """
        if image_size is None:
            image_size = spotify.ImageSize.NORMAL
        cover_id = lib.sp_album_cover(self._sp_album, int(image_size))
        if cover_id == ffi.NULL:
            return None
        sp_image = lib.sp_image_create(self._session._sp_session, cover_id)
        return spotify.Image(
            self._session, sp_image=sp_image, add_ref=False, callback=callback)
Esempio n. 7
0
 def get_image(sp_artistbrowse, key):
     image_id = lib.sp_artistbrowse_portrait(sp_artistbrowse, key)
     sp_image = lib.sp_image_create(image_id)
     return spotify.Image(
         self._session, sp_image=sp_image, add_ref=False,
         callback=callback)
Esempio n. 8
0
 def get_image(sp_artistbrowse, key):
     image_id = lib.sp_artistbrowse_portrait(sp_artistbrowse, key)
     sp_image = lib.sp_image_create(image_id)
     return spotify.Image(sp_image=sp_image, add_ref=False)