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 yourSession
instance to get aToplist
back.-
type
= None¶ A
ToplistType
instance 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
ToplistRegion
instance, 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
region
isToplistRegion.USER
, then this field specifies which user the toplist is for.Changing this field has no effect on existing toplists.
-
loaded_event
= None¶ threading.Event
that 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
timeout
seconds with no resultsTimeout
is raised. Iftimeout
isNone
the default timeout is used.The method returns
self
to allow for chaining of calls.
-
property
error
¶ An
ErrorType
associated 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
-1
if the request was served from local cache. ReturnsNone
if 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.
-