Toplists¶
-
class
spotify.Toplist(session, type=None, region=None, canonical_username=None, callback=None, sp_toplistbrowse=None, add_ref=True)[source]¶ A Spotify toplist of artists, albums or tracks that are currently most popular worldwide or in a specific region.
Call the
get_toplist()method on yourSessioninstance to get aToplistback.-
type= None¶ A
ToplistTypeinstance that specifies what kind of toplist this is: top artists, top albums, or top tracks.Changing this field has no effect on existing toplists.
-
region= None¶ Either a
ToplistRegioninstance, or a 2-letter ISO 3166-1 country code, that specifies the geographical region this toplist is for.Changing this field has no effect on existing toplists.
-
canonical_username= None¶ If
regionisToplistRegion.USER, then this field specifies which user the toplist is for.Changing this field has no effect on existing toplists.
-
loaded_event= None¶ threading.Eventthat is set when the toplist is loaded.
-
property
is_loaded¶ Whether the toplist’s data is loaded yet.
-
load(timeout=None)[source]¶ Block until the user’s data is loaded.
After
timeoutseconds with no resultsTimeoutis raised. IftimeoutisNonethe default timeout is used.The method returns
selfto allow for chaining of calls.
-
property
error¶ An
ErrorTypeassociated with the toplist.Check to see if there was problems creating the toplist.
-
property
backend_request_duration¶ The time in ms that was spent waiting for the Spotify backend to create the toplist.
Returns
-1if the request was served from local cache. ReturnsNoneif the toplist isn’t loaded yet.
-
property
tracks¶ The tracks in the toplist.
Will always return an empty list if the toplist isn’t loaded.
-
property
albums¶ The albums in the toplist.
Will always return an empty list if the toplist isn’t loaded.
-
property
artists¶ The artists in the toplist.
Will always return an empty list if the toplist isn’t loaded.
-