From adeb7acb389502196be446145faf84c717a0c51b Mon Sep 17 00:00:00 2001 From: TLSM Date: Mon, 21 Nov 2022 18:52:21 -0500 Subject: [PATCH] archive_url: suppress errors on remote failure. ghostarchive has been giving us 500 backs lately. They are making an absolute mess of the log for a non-central, opportunistic feature, and we already eat exceptions for archive.org. We merely extend that to ghostarchive. --- files/helpers/actions.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index eda96162c..7ad245bdd 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -16,12 +16,17 @@ from files.helpers.get import * from files.helpers.sanitize import * from files.helpers.slots import check_slots_command -headers = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'} def _archiveorg(url): - try: requests.get(f'https://web.archive.org/save/{url}', headers=headers, timeout=10, proxies=proxies) + headers = {'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'} + try: + requests.get(f'https://web.archive.org/save/{url}', + headers=headers, timeout=10, proxies=proxies) + except: pass + try: + requests.post('https://ghostarchive.org/archive2', data={"archive": url}, + headers=headers, timeout=10, proxies=proxies) except: pass - requests.post('https://ghostarchive.org/archive2', data={"archive": url}, headers=headers, timeout=10, proxies=proxies) def archive_url(url):