Right now I am just trying to print out the JSON through python. Eventually I will be using information from the requested JSON but I am stuck at just getting it into something I can work with.
import urllib
import urllib.request
import dateutil
import json
API_KEY = open("/Users/Sean/Documents/Yer.txt", "r")
API_KEY = API_KEY.read()
url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUiufyZv8iRPTafTw0D4CvnQ&key='+API_KEY
response = urllib.request.urlopen(url)
videos = json.load(response)
print(videos)
This is where I started. I get the error
the JSON object must be str, not 'bytes'
on the "videos = json.load(response)" line.
Searching around and ended up trying out
videos = json.load(response.decode())
With that I get this error
Traceback (most recent call last): File "C:\Users\Sean\Documents\NeebsBot\NeebsBot\NeebsBot\NeebsBot.py", line 13, in videos = json.load(response.decode()) AttributeError: 'HTTPResponse' object has no attribute 'decode' Press any key to continue . . .
Searched again and tried this.
response = urllib.request.urlopen(url)
content = response.read()
videos = json.loads(content.decode('utf8'))
print(videos)
And I get this when I run
'charmap' codec can't encode character '\xa9' in position 1573: character maps to
All the solutions I have found online always brings me back to these errors.