I know that I'm dyslexic and I don't have a PhD but I always find Google APIs incomprehensible.
I just need an example on the following:
Get the '/music/genre' list and then get the subgenres ('/music/genre/subgenre') of the e.g. first genre. And then print the /common/topic/alias
if any for each of them.
My code:
import json
import requests
query = json.dumps( [{'id': None, 'name': None, 'type': '/music/genre'}])
r = requests.get('https://www.googleapis.com/freebase/v1/mqlread?query=%s' % query )
for i in r.json()['result'][:1]:
print requests.get('https://www.googleapis.com/freebase/v1/mqlread?query=%s' % json.dumps([i]) ).text
However the later print returns:
{"result": [
{
"id": "/en/classic_rock",
"type": "/music/genre",
"name": "Classic rock"
}
]}
If I try to get the topic "/en/blues" as the example here with:
print requests.get('https://www.googleapis.com/freebase/v1/topic/en/blues').text
It returns a list related to /en/blues
query.
I also tried the following to get directly the subgenre list:
for i in r.json()['result'][:1]:
i['type'] = '/music/genre/subgenre'
print requests.get('https://www.googleapis.com/freebase/v1/mqlread?query=%s' % json.dumps([i]) ).text
But returns an empty array.