fix ar15.com links

master
Aevann 2024-01-07 03:02:55 +02:00
parent 90f6b293fa
commit f2fd0db3c5
1 changed files with 5 additions and 3 deletions

View File

@ -776,6 +776,8 @@ def normalize_url(url):
url = giphy_regex.sub(r'\1.webp', url)
domain = tldextract.extract(url).registered_domain
if not url.startswith('/') and not url.startswith('https://rdrama.net') and not url.startswith('https://watchpeopledie.tv'):
try: parsed_url = urlparse(url)
except:
@ -783,7 +785,7 @@ def normalize_url(url):
abort(500)
netloc = parsed_url.netloc
path = parsed_url.path.rstrip('/')
path = parsed_url.path
qd = parse_qs(parsed_url.query, keep_blank_values=True)
filtered = {}
@ -793,7 +795,6 @@ def normalize_url(url):
filtered['v'] = path.split('/')[-1]
path = '/watch'
domain = tldextract.extract(netloc).registered_domain
filtered |= {k: val for k, val in qd.items() if not val[0] or is_whitelisted(domain, k)}
if netloc == 'old.reddit.com' and reddit_comment_link_regex.fullmatch(url):
@ -807,7 +808,8 @@ def normalize_url(url):
fragment=parsed_url.fragment)
url = urlunparse(new_url)
url = url.rstrip('/')
if domain != 'ar15.com':
url = url.rstrip('/')
url = imgur_regex.sub(r'\1_d.webp?maxwidth=9999&fidelity=grand', url)