Strip JSON response from Google API of the 5-byte prefix
Read more here: * https://github.com/google/gitiles/issues/22 * https://github.com/google/gitiles/issues/82
This commit is contained in:
parent
c5d695b59e
commit
6d9f04355c
@ -89,8 +89,11 @@ def language_list_from_api():
|
||||
"""Return a JSON with a list of available languages from Google API."""
|
||||
listurl = urllib.parse.urljoin(API_URL, '?format=JSON')
|
||||
response = urllib.request.urlopen(listurl)
|
||||
# TODO: what's up with the first 4 characters?
|
||||
entries = json.loads(response.read().decode('utf-8')[4:])['entries']
|
||||
# A special 5-byte prefix must be stripped from the response content
|
||||
# See: https://github.com/google/gitiles/issues/22
|
||||
# https://github.com/google/gitiles/issues/82
|
||||
json_content = response.read()[5:]
|
||||
entries = json.loads(json_content.decode('utf-8'))['entries']
|
||||
return entries
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user