handle local path redirects

This commit is contained in:
cquest 2023-01-15 09:35:04 +01:00
parent e3292c74bd
commit 1165374824

View File

@ -18,6 +18,10 @@ import requests
def unredir(redir):
r = requests.get(redir, allow_redirects=False)
while r.status_code in {301, 302}:
if 'http' not in r.headers.get('Location'):
redir = re.sub(r'(https?://.*)/.*', r'\1', redir) + \
r.headers.get('Location')
else:
redir = r.headers.get('Location')
print('redir', redir)
if '//ow.ly/' in redir or '//bit.ly/' in redir: