Thank you kingosticks for your reply.
I have already read the documentation and also installed api-explorer.
I have previously worked with numerous online API’s ( 7, including this from TMDB , you can see it here https://github.com/fredele
But this API gives me some headache … I explain:
The search functions gives me a dict. with a result key with is a list.
Is the length of this list always 1 ?
In the result key I got a tracks key wich contains all the tracks.
A track has an album key, and other keys like name, uri,genre, artists.
But the album key has also an artists key ?
Is the artist in albums the AlbumArtist id3 tag and the other the Artist id3 tag ? It seams so.
If I pick from each track the album dict and make a list of it, deleting the duplicates, I offently end with a list where I got more than once the same album name : so isn’t the album dict. unique for each album ?
It is, but a very slight difference in the tags ends up with 2 different albums !
What are the scanned tags wich MUST be identical in each file of an album to have a single Album ?
Album,AlbumArtist, Musicbrainz Album, … what else ?
As an example, the player Quodlibet relies on the MusicBrainz album ID or labelid to have different albums.Here, we have clearly numerous more tags, it seams. A single uncorrect value, and all is messed up …(?)
Here’s a dummy sample code I wrote. Would it be the right way to use the API ? Any remarks ?
As I see, i must do the whole part of the tracks filtering myself (?), because there isnt’ a functions who gives me directly all different albums ?
Many questions, I know …
Thanks for your time.
import requests
import json
def main():
url = "http://localhost:6680/mopidy/rpc"
headers = {'content-type': 'application/json'}
search = {
"method": "core.library.search",
"params": {"query": { "genre":["Jazz"]},"uris" : None, "exact" : False},
"jsonrpc": "2.0",
"id": 1,
}
response = requests.post(url, data=json.dumps(search), headers=headers).json()
print json.dumps(response)
# get all the tracks, is the lengh always 1 ?
tracks = response["result"][0]["tracks"]
# get album dict. out for each track
albums = [track["album"] for track in tracks ]
unique_album = []
# delete duplicated albums ....
for album in albums:
if album not in unique_album:
unique_album.append(album)
# I got offen more than 1 dict. with the same name here, because of slight differences in the tags !
for album in unique_album:
print album["name"]
if __name__ == "__main__":
main()
And Have a merry chrismas everybody here !