XBMC plugin are written in Python and as you already know there is no SDK for this language. The only way I found to do this is to open a web page which integrates a Deezer player in it. My web page and my Python plugin communicate by an Ajax communication. I just wanted to know if it's possible to receive an audio stream by the Deezer api. As Deezer sometimes requires a captcha to login the auto login features was removed. Instead you have to manually insert a valid Deezer cookie to the settings.ini. The relevant cookie is the arl cookie. Get started with Deezer's Spleeter: newly released open source tool, Spleeter, is nothing short of remarkable.
Remove universal wheel option (5f31f14)Fix missing requirements when running tests (cb7d421)Fix configuration for python-semantic-release (dd446d2). Class deezer.client.Client(appid=None, appsecret=None, accesstoken=None, headers=None,.kwargs) ¶ A client to retrieve some basic infos about Deezer resourses. Create a client instance with the provided options. Options should be passed in to the constructor as kwargs.
Implements a client class to query theDeezer API
deezer.client.
Client
(app_id=None, app_secret=None, access_token=None, headers=None, **kwargs)¶A client to retrieve some basic infos about Deezer resourses.
Create a client instance with the provided options. Options shouldbe passed in to the constructor as kwargs.
This client provides several method to retrieve the content of mostsort of Deezer objects, based on their json structure.
Headers can be forced by using the headers
kwarg.For example, use Accept-Language
header to force the output language.
app_id – appliication ID.
app_secret – application secret.
access_token – user access token.
headers – a dictionary of headers to be used.
Deprecated since version 1.4.0.
The following parameters will be removed in the next major version:
host - override the default hostname.
use_ssl - connect using HTTP if set to False.
advanced_search
(terms, relation=None, index=0, limit=25, **kwargs)¶Advanced search of track, album or artist.
See Search section of Deezer API for search terms.
a list of Resource
objects.
get_album
(object_id, relation=None, **kwargs)¶Get the album with the provided id
an Album
object
get_artist
(object_id, relation=None, **kwargs)¶Get the artist with the provided id
an Artist
object
get_chart
(relation=None, index=0, limit=10, **kwargs)¶Get chart
a list of Resource
objects.
get_comment
(object_id)¶Get the comment with the provided id
a Comment
object
get_episode
(object_id)¶Get the episode with the provided id
a Episode
object
get_genre
(object_id)¶Get the genre with the provided id
a Genre
object
get_genres
()¶a list of Genre
objects.
get_object
(object_t, object_id=None, relation=None, parent=None, **kwargs)¶Actually query the Deezer API to retrieve the object
json dictionary
get_playlist
(object_id)¶Get the playlist with the provided id
a Playlist
object
get_podcast
(object_id)¶Get the podcast with the provided id
a Podcast
object
get_radio
(object_id=None)¶Get the radio with the provided id.
a Radio
object
get_radios
()¶Get a list of radios.
a list of Radio
objects
get_radios_top
()¶Get the top radios (5 radios).
a Radio
object
get_track
(object_id)¶Get the track with the provided id
a Track
object
get_user
(object_id)¶Get the user with the provided id
a User
object
object_url
(object_t, object_id=None, relation=None, **kwargs)¶Helper method to build the url to query to access the objectpassed as parameter
TypeError – if the object type is invalid
scheme
¶Get the http prefix for the address depending on the use_ssl attribute
search
(query, relation=None, index=0, limit=25, **kwargs)¶Search track, album, artist or user
a list of Resource
objects.
url
(request=')¶Build the url with the appended request if provided.
First steps¶
To start calling the API, you first need to instantiate aClient
:
From there, you can search for some terms:
The above returned a lot of tracks. If you wanted to search for artistsinstead, you may do so by specifying the relation
argument:
The relation
parameter accepts any resource name as value. The name ofa resource is a string with the class name in lowercase. This isexplained in a following section.
Main concepts¶
As we just seen above, the entry point is theClient
class,which gives access to a number of methods. The methods are attempting tomap to the REST API endpoints from Deezer.
You may have noticed from the above examples, but depending on theendpoint that is being called, the methods will return various type ofresources. All the resources are listed in theresources reference page.
More examples¶
Deezer Python Download
Getting a field about a resource¶
When you ge a resource, you have access to all the fields that are inthe REST API response. For example, all the fields presented in thedocumentation for the trackobject are accessible asattribute on the Track
resource:
Navigating resource relationships¶
As well as giving access to its own attributes, a resource also givesaccess to other related resources.
Deezer-python Example
For example, when you get an Artist
, youmay call one of the methods documented to get the artist’s albums, thenfrom an Album
get its tracks, and from aTrack
you may go back to theAlbum
or theArtist
.
Let’s try from the initial example:
As you can see, it doesn’t look like we’re making API requests, butunder the hood, the client is passed around and makes further API callsas needed.
You can tell the difference, though: attributes access are using thedata from the resource which was already fetched, while calling a methodon the resource does extra API requests.
Getting the raw data¶
At some point, you might want to get the resources exported as Pythondictionaries to store them somewhere else or transform them further.
Each resource has a asdict()
method to export its content asdictionary:
Authentication¶
The deezer-python
library doesn’t handle the authentication process,but it accepting an API token, which one can obtain using otherlibraries.
Obtaining a authentication token is better done client side, for examplewith Python Social Auth, whichsupports Deezer authentication.
Once the OAuth2 flow is complete, Deezer should give you a token whichcan be passed to the Client
class:
From there, you should be able to perform authenticated requests.