Update valvesounds.py
This commit is contained in:
parent
b460fb2fd2
commit
a69c4eceb3
1 changed files with 1 additions and 8 deletions
|
@ -4,16 +4,9 @@ import urllib2
|
||||||
|
|
||||||
|
|
||||||
def get_sound_info(game, search):
|
def get_sound_info(game, search):
|
||||||
# Currently, http.get_json doesn't support adding headers.
|
|
||||||
def get_json(url):
|
|
||||||
request = urllib2.Request(url)
|
|
||||||
request.add_header('User-Agent', http.ua_cloudbot)
|
|
||||||
opener = urllib2.build_opener()
|
|
||||||
return json.loads(opener.open(request).read())
|
|
||||||
|
|
||||||
search = search.replace(" ", "+")
|
search = search.replace(" ", "+")
|
||||||
try:
|
try:
|
||||||
data = get_json("http://p2sounds.blha303.com.au/search/%s/%s" % (game, search))
|
data = http.get_json("http://p2sounds.blha303.com.au/search/%s/%s?format=json" % (game, search))
|
||||||
except urllib2.HTTPError as e:
|
except urllib2.HTTPError as e:
|
||||||
return "Error: " + json.loads(e.read())["error"]
|
return "Error: " + json.loads(e.read())["error"]
|
||||||
items = []
|
items = []
|
||||||
|
|
Reference in a new issue