From b93ca75f99288aa661cdd298a0d2a2d8db62d87c Mon Sep 17 00:00:00 2001 From: Androz 2091 Date: Fri, 15 Mar 2024 21:17:53 +0100 Subject: [PATCH] add cloudflare detection --- src/tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tasks.py b/src/tasks.py index 49356ec..a2be723 100644 --- a/src/tasks.py +++ b/src/tasks.py @@ -75,7 +75,8 @@ def download_file(package_status_id, package_id, link, session): if not check_whitelisted_link(link): print('checking content type') r = requests.head(link, allow_redirects=True) - if r.status_code != 200 or 'content-type' not in r.headers or 'application/octet-stream' not in r.headers['content-type']: + # check if location starts with https://storage.googleapis.com after 302 + if r.status_code != 302 and not r.headers['Location'].startswith('https://storage.googleapis.com'): print('The link does not point to a valid file.') raise Exception('INVALID_LINK')