From 33c6f8e7972797ec71e49a9cefd7305fa10e5c52 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 28 Apr 2019 11:07:36 -0400 Subject: [PATCH] Fix some reasons bot may encounter HTTP exceptions when reversing images --- src/utils/scraper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/scraper.py b/src/utils/scraper.py index a8e6ee2..6fd0266 100644 --- a/src/utils/scraper.py +++ b/src/utils/scraper.py @@ -26,13 +26,18 @@ async def get_post(url): if value != '#': ident = re.search('show/([0-9]+)', value).group(1) post = await u.fetch('http://e621.net/post/show.json', params={'id': ident}, json=True) + + if (post['status'] == 'deleted'): + ident = re.search('#(\\d+)', post['delreason']).group(1) + post = await u.fetch('http://e621.net/post/show.json', params={'id': ident}, json=True) + return post else: raise IndexError except IndexError: try: - raise exc.MatchError(re.search('\/([^\/]+)$', url).group(1)) + raise exc.MatchError(re.search('\\/([^\\/]+)$', url).group(1)) except AttributeError: raise exc.MissingArgument