Skip to content

Commit

Permalink
add an exception for when derpi's anti-DDoS is active
Browse files Browse the repository at this point in the history
  • Loading branch information
ask-compu authored Apr 13, 2020
1 parent f293d63 commit 7f35f57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,14 @@ def get_id(link):
id = get_id(uri)
if not id:
return gettitle(uri)
json_data = web.get('https://derpibooru.org/api/v1/json/images/{0}'.format(id))
from urllib.error import HTTPError
try:
json_data = web.get('https://derpibooru.org/api/v1/json/images/{0}'.format(id))
except HTTPError as err:
if err.code == 403:
return "Sorry! Derpibooru's API seems to be broken at the moment!"
else:
raise
postdataimage = json.loads(json_data, encoding='utf-8')
postdata = postdataimage['image']
if postdata['deletion_reason']:
Expand Down

0 comments on commit 7f35f57

Please sign in to comment.