Skip to content

Commit

Permalink
added fix for deleted derpibooru image links
Browse files Browse the repository at this point in the history
  • Loading branch information
ask-compu committed Apr 15, 2016
1 parent febd193 commit cb539ca
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,20 @@ def get_id(link):
return gettitle(uri)
json_data = web.get('http://derpiboo.ru/{0}.json'.format(id))
postdata = json.loads(json_data, encoding='utf-8')
if 'deletion_reason' in postdata:
deleted = postdata['deletion_reason']
created_zulu = postdata['created_at']
try:
import dateutil.parser
dt = dateutil.parser.parse(created_zulu)
created_unix = calendar.timegm(dt.timetuple())
timestamp1 = time.gmtime(created_unix)
created_format = time.strftime('%A %B %d, %Y at %I:%M:%S %p GMT',timestamp1)
created_format = ", it was uploaded on " + created_format
except:
created_format = ""

return '\002Derpibooru -- \017This image was deleted because of "' + deleted + '"' + created_format
tags = postdata['tags'].split(', ')

artists = []
Expand Down

0 comments on commit cb539ca

Please sign in to comment.