Search code examples
gracenotepygn

GraceNote rhythm API with Pygn


The following works and retrurns a list of semmingly random tracks which GraceNote thinks are similar to Bowe's work:

radioPlayList = pygn.createRadio(GRACENOTE_CLIENT_ID, GRACENOTE_USER_ID, artist='Bowie', count='3');

However, I would strongly prefer to pass a genre, rather than an atrist - I just can't figure our how.

This radioPlayList = pygn.createRadio(GRACENOTE_CLIENT_ID, GRACENOTE_USER_ID, genre='38', count='3'); returns <RESPONSES>\n <RESPONSE STATUS="NO_MATCH">\n </RESPONSE>\n</RESPONSES> which lead me to beleive that Genre should not just be a simple number.

And trying to give the genre as a text, radioPlayList = pygn.createRadio(GRACENOTE_CLIENT_ID, GRACENOTE_USER_ID, genre='Oldies', count='3'); gives <RESPONSES>\n <MESSAGE>GCSP: RADIOCREATE error: [8] radio: Invalid attribute seed.</MESSAGE>\n <RESPONSE STATUS="ERROR">\n </RESPONSE>\n</RESPONSES>\n so that is obviously not the way to do it.

QUESTION: how can I pass a Genre (only) and get a radio playlist in return?

The only Pygn docuemntation which I can find does not help. I am hoping that @cweichen will se thsi question & help me. Does anyone else know how?


[Update] Looking in the code of Pygn's test.py, I see

# Example how to create a radio playlist by genre classical music result = pygn.createRadio(clientID, userID, genre='36061', popularity ='1000', similarity = '1000') print(json.dumps(result, sort_keys=True, indent=4))

Question: where do I get a list of those genre values? The file readme.md says genre: a genre ID from the genres below, but here is no list below.


Solution

  • To get the list of genres (or moods, or eras) you need to make a call to the "fieldvalues" API - this isn't in pygn yet, but you can see how to do it here:

    https://developer.gracenote.com/rhythm-api#attribute-station

    This call will give you the list of supported genres:

    https://cXXXXXXX.web.cddbp.net/webapi/json/1.0/radio/fieldvalues?fieldname=RADIOGENRE&client=CLIENT_ID&user=USER_ID

    You can then use the returned ID's with pygn.createRadio()