Object

Inheritance diagram of musify.libraries.remote.spotify.object

Implements all Remote object types for Spotify.

Classes:

SpotifyTrack(response[,Β api,Β skip_checks])

Extracts key track data from a Spotify API JSON response.

SpotifyCollectionLoader(response[,Β api,Β ...])

Generic class for storing a collection of Spotify objects that can be loaded from an API response.

SpotifyPlaylist(response[,Β api,Β skip_checks])

Extracts key playlist data from a Spotify API JSON response.

SpotifyAlbum(response[,Β api,Β skip_checks])

Extracts key album data from a Spotify API JSON response.

SpotifyArtist(response[,Β api,Β skip_checks])

Extracts key artist data from a Spotify API JSON response.

class musify.libraries.remote.spotify.object.SpotifyTrack(response, api=None, skip_checks=False)

Bases: SpotifyItem, RemoteTrack

Extracts key track data from a Spotify API JSON response.

Parameters:

response (dict[str, Any]) – The Spotify API JSON response.

Attributes:

name

A name for this object

title

This track's title

artist

Joined string representation of all artists featured on this track

artists

List of all artists featured on this track.

album

The album this track is featured on

album_artist

The artist of the album this track is featured on

track_number

The position this track has on the album it is featured on

track_total

The track number of tracks on the album this track is featured on

genres

List of genres for the album this track is featured on.

year

The year this track was released

month

The month this track was released

day

The day this track was released

bpm

The tempo of this track

key

The key of this track in alphabetical musical notation format

disc_number

The number of the disc from the album this track is featured on

disc_total

The total number the discs from the album this track is featured on

compilation

Is the album this track is featured on a compilation

comments

Comments associated with this track set by the user

image_links

The images associated with the album this track is featured on in the form {<image name/type>: <image link>}

has_image

Does the album this track is associated with have an image

length

Total duration of this track in seconds

rating

The rating for this track

Methods:

refresh([skip_checks])

Refresh this object by updating from the stored API response.

load(value,Β api[,Β features,Β analysis,Β ...])

Generate a new object of this class, calling all required endpoints to get a complete set of data for this item type.

reload([features,Β analysis,Β extend_album,Β ...])

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

property name

A name for this object

property title: str

This track’s title

property artist

Joined string representation of all artists featured on this track

property artists: list[SpotifyArtist]

List of all artists featured on this track.

property album

The album this track is featured on

property album_artist

The artist of the album this track is featured on

property track_number: int

The position this track has on the album it is featured on

property track_total

The track number of tracks on the album this track is featured on

property genres

List of genres for the album this track is featured on. If not found, genres from the main artist are given.

property year

The year this track was released

property month

The month this track was released

property day

The day this track was released

property bpm

The tempo of this track

property key

The key of this track in alphabetical musical notation format

property disc_number: int

The number of the disc from the album this track is featured on

property disc_total

The total number the discs from the album this track is featured on

property compilation: bool

Is the album this track is featured on a compilation

property comments

Comments associated with this track set by the user

The images associated with the album this track is featured on in the form {<image name/type>: <image link>}

property has_image

Does the album this track is associated with have an image

property length

Total duration of this track in seconds

property rating

The rating for this track

refresh(skip_checks=False)

Refresh this object by updating from the stored API response. Useful for updating stored variables after making changes to the stored API response manually.

Return type:

None

classmethod load(value, api, features=False, analysis=False, extend_album=False, extend_artists=False, *_, **__)

Generate a new object of this class, calling all required endpoints to get a complete set of data for this item type.

value may be:
  • A string representing a URL/URI/ID.

  • A remote API JSON response for a collection with a valid ID value under an id key.

  • An object of the same type as this collection. The remote API JSON response will be used to load a new object.

Parameters:
  • value (str | Mapping[str, Any] | RemoteResponse) – The value representing some remote object. See description for allowed value types.

  • api (SpotifyAPI) – An authorised API object to load the object from.

Return type:

Self

reload(features=False, analysis=False, extend_album=False, extend_artists=False, *_, **__)

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

Return type:

None

class musify.libraries.remote.spotify.object.SpotifyCollectionLoader(response, api=None, skip_checks=False)

Bases: RemoteCollectionLoader, SpotifyObject, ABC, Generic

Generic class for storing a collection of Spotify objects that can be loaded from an API response.

Methods:

load(value,Β api[,Β items,Β leave_bar])

Generate a new object, calling all required endpoints to get a complete set of data for this item type.

classmethod load(value, api, items=(), leave_bar=True, *args, **kwargs)

Generate a new object, calling all required endpoints to get a complete set of data for this item type.

value may be:
  • A string representing a URL/URI/ID.

  • A remote API JSON response for a collection with a valid ID value under an id key.

  • An object of the same type as this collection. The remote API JSON response will be used to load a new object.

You may also provide a set of kwargs relating that will extend aspects of the response before using it to initialise a new object. See reload() for possible extensions.

Parameters:
  • value (str | Mapping[str, Any] | RemoteResponse) – The value representing some remote collection. See description for allowed value types.

  • api (SpotifyAPI) – An authorised API object to load the object from.

  • items (Iterable[T] (default: ())) – Optionally, give a list of available items to build a response for this collection. In doing so, the method will first try to find the API responses for the items of this collection in the given list before calling the API for any items not found there. This helps reduce the number of API calls made on initialisation.

Return type:

Self

class musify.libraries.remote.spotify.object.SpotifyPlaylist(response, api=None, skip_checks=False)

Bases: SpotifyCollectionLoader[SpotifyTrack], RemotePlaylist[SpotifyTrack]

Extracts key playlist data from a Spotify API JSON response.

Parameters:

response (dict[str, Any]) – The Spotify API JSON response

Attributes:

name

A name for this object

description

Description of this playlist

public

Can other users access this playlist

collaborative

Are other users allowed to modify this playlist

followers

The number of followers this playlist has

owner_name

The name of the owner of this playlist

owner_id

The ID of the owner of this playlist

tracks

The tracks in this playlist

track_total

The total number of tracks in this playlist

image_links

The images associated with this playlist in the form {<image name/type>: <image link>}

has_image

Does this playlist have an image

date_created

datetime object representing when the first track was added to this playlist

date_modified

datetime object representing when a track was most recently added/removed

date_added

A map of {<URI>: <date>} for each item for when that item was added to the playlist

Methods:

refresh([skip_checks])

Refresh this object by updating from the stored API response.

reload([extend_tracks,Β extend_features])

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

property name

A name for this object

property description

Description of this playlist

property public

Can other users access this playlist

property collaborative

Are other users allowed to modify this playlist

property followers

The number of followers this playlist has

property owner_name

The name of the owner of this playlist

property owner_id

The ID of the owner of this playlist

property tracks

The tracks in this playlist

property track_total

The total number of tracks in this playlist

The images associated with this playlist in the form {<image name/type>: <image link>}

property has_image

Does this playlist have an image

property date_created

datetime object representing when the first track was added to this playlist

property date_modified

datetime object representing when a track was most recently added/removed

property date_added

A map of {<URI>: <date>} for each item for when that item was added to the playlist

refresh(skip_checks=False)

Refresh this object by updating from the stored API response. Useful for updating stored variables after making changes to the stored API response manually.

Return type:

None

reload(extend_tracks=False, extend_features=False, *_, **__)

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

Return type:

None

class musify.libraries.remote.spotify.object.SpotifyAlbum(response, api=None, skip_checks=False)

Bases: RemoteAlbum[SpotifyTrack], SpotifyCollectionLoader[SpotifyTrack]

Extracts key album data from a Spotify API JSON response.

Parameters:

response (dict[str, Any]) – The Spotify API JSON response

Attributes:

name

The album name

tracks

The tracks on this album

artists

List of artists ordered by frequency of appearance on the tracks on this album

artist

Joined string representation of all artists on this album ordered by frequency of appearance

album_artist

The album artist for this album

track_total

The total number of tracks on this album

genres

List of genres ordered by frequency of appearance on the tracks on this album

year

The year this album was released

month

The month this album was released

day

The day this album was released

compilation

Is this album a compilation

image_links

The images associated with this album in the form {<image name/type>: <image link>}

has_image

Does this album have an image

rating

Rating of this album

Methods:

refresh([skip_checks])

Refresh this object by updating from the stored API response.

reload([extend_artists,Β extend_tracks,Β ...])

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

property name

The album name

property tracks: list[SpotifyTrack]

The tracks on this album

property artists: list[SpotifyArtist]

List of artists ordered by frequency of appearance on the tracks on this album

property artist

Joined string representation of all artists on this album ordered by frequency of appearance

property album_artist

The album artist for this album

property track_total

The total number of tracks on this album

property genres

List of genres ordered by frequency of appearance on the tracks on this album

property year

The year this album was released

property month

The month this album was released

property day

The day this album was released

property compilation

Is this album a compilation

The images associated with this album in the form {<image name/type>: <image link>}

property has_image

Does this album have an image

property rating

Rating of this album

refresh(skip_checks=False)

Refresh this object by updating from the stored API response. Useful for updating stored variables after making changes to the stored API response manually.

Return type:

None

reload(extend_artists=False, extend_tracks=False, extend_features=False, *_, **__)

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

Return type:

None

class musify.libraries.remote.spotify.object.SpotifyArtist(response, api=None, skip_checks=False)

Bases: RemoteArtist[SpotifyAlbum], SpotifyCollectionLoader[SpotifyAlbum]

Extracts key artist data from a Spotify API JSON response.

Attributes:

name

The artist name

items

The albums this artist is featured on

artist

The artist name

albums

List of albums ordered by frequency of appearance on the tracks by this artist

genres

List of genres for this artist

image_links

The images associated with this artist in the form {<image name/type>: <image link>}

rating

The popularity of this artist

followers

The total number of followers for this artist

Methods:

refresh([skip_checks])

Refresh this object by updating from the stored API response.

reload([extend_albums,Β extend_tracks,Β ...])

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

property name

The artist name

property items: list[SpotifyAlbum]

The albums this artist is featured on

property artist

The artist name

property albums: list[SpotifyAlbum]

List of albums ordered by frequency of appearance on the tracks by this artist

property genres

List of genres for this artist

The images associated with this artist in the form {<image name/type>: <image link>}

property rating

The popularity of this artist

property followers: int | None

The total number of followers for this artist

refresh(skip_checks=False)

Refresh this object by updating from the stored API response. Useful for updating stored variables after making changes to the stored API response manually.

Return type:

None

reload(extend_albums=False, extend_tracks=False, extend_features=False, *_, **__)

Reload this object from the API, calling all required endpoints to get a complete set of data for this item type.

Return type:

None