mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Catch HTTP errors for Imgur upload
This commit is contained in:
parent
ca29333cd0
commit
bc42e79bb5
1 changed files with 13 additions and 10 deletions
|
@ -546,16 +546,19 @@ def uploadToImgur(imgPath, imgTitle=''):
|
||||||
data['title'] = imgTitle
|
data['title'] = imgTitle
|
||||||
data['name'] = imgTitle + '.jpg'
|
data['name'] = imgTitle + '.jpg'
|
||||||
|
|
||||||
request = urllib2.Request('https://api.imgur.com/3/image', headers=headers, data=urllib.urlencode(data))
|
try:
|
||||||
response = urllib2.urlopen(request)
|
request = urllib2.Request('https://api.imgur.com/3/image', headers=headers, data=urllib.urlencode(data))
|
||||||
response = json.loads(response.read())
|
response = urllib2.urlopen(request)
|
||||||
|
response = json.loads(response.read())
|
||||||
|
|
||||||
if response.get('status') == 200:
|
if response.get('status') == 200:
|
||||||
logger.debug(u"PlexPy Helpers :: Image uploaded to Imgur.")
|
logger.debug(u"PlexPy Helpers :: Image uploaded to Imgur.")
|
||||||
img_url = response.get('data').get('link', '')
|
img_url = response.get('data').get('link', '')
|
||||||
elif response.get('status') >= 400 and response.get('status') < 500:
|
elif response.get('status') >= 400 and response.get('status') < 500:
|
||||||
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur: %s" % response.reason)
|
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur: %s" % response.reason)
|
||||||
else:
|
else:
|
||||||
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur.")
|
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur.")
|
||||||
|
except urllib2.HTTPError as e:
|
||||||
|
logger.warn(u"PlexPy Helpers :: Unable to upload image to Imgur: %s" % e)
|
||||||
|
|
||||||
return img_url
|
return img_url
|
Loading…
Add table
Add a link
Reference in a new issue