I’m using the Requests library to make api calls. So far I’ve had no issues getting all the values I need, until now. I’m trying to obtain a value inside a nested dictionary object. Below is the code I’m using. My end goal is to list the author’s name and timestamp in the details container next to the itemlist. Just like this Add-on screen view (right-hand side description/info)
For testing I’ve been trying to get the pull request author’s name, but for some reason I can’t seem to get it inside the addon code. Outside of the addon code (testing in EventGhost using Python Script action) I can get the value fine both ways that I try below.
link = 'https://api.github.com/repos/caffeinatedMike/testing/pulls'
HEADERS = {'user-agent':'test-account'}
r = requests.get(link,headers=HEADERS)
if r.status_code == 200:
j_obj = json.loads(r.text)
if not len(j_obj) == 0:
for pull in j_obj:
#Attempt 1) author = pull['user']['login']
#Attempt 2) author = pull['user'].get('login')
xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(addonname, author, time, icon))
list_item = xbmcgui.ListItem(label=pull['title'], artist=author)
The first issue with the code is I’m not able to get the author value from the response. Usually it’s giving me “Key doesn’t exist” or something about indices. The second issue is Kodi through another error saying that artist isn’t a valid parameter. Does this have anything to do with the fact that the addon I’m working on is a program addon and not a video addon?
Any help and/or advice would be greatly appreciated.
Github Pull Request Api page for reference.