Aevann 2023-05-07 22:44:34 +03:00
parent 4056ce1e91
commit 619bdba5b2
2 changed files with 2 additions and 2 deletions

View File

@ -23,8 +23,7 @@ def normalize_urls_runtime(body, v):
if v.reddit != 'old.reddit.com':
body = reddit_to_vreddit_regex.sub(rf'\1https://{v.reddit}/\2/', body)
if v.nitter:
body = body.replace('https://twitter.com/', 'https://nitter.lacontrevoie.fr/')
body = body.replace('https://nitter.lacontrevoie.fr/i/', 'https://twitter.com/i/')
body = twitter_to_nitter_regex.sub(r'\1https://nitter.lacontrevoie.fr/', body)
if v.imginn:
body = body.replace('https://instagram.com/p/', 'https://imginn.com/p/')
return body

View File

@ -101,6 +101,7 @@ greentext_regex = re.compile("(\n|^)>([^ >][^\n]*)", flags=re.A)
ascii_only_regex = re.compile("[ -~]+", flags=re.A)
reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|u)\/', flags=re.A)
twitter_to_nitter_regex = re.compile('(^|>|")https:\/\/twitter.com\/(?!i\/)', flags=re.A)
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2})(?:-[A-z]{2})" "?|beta|i|m|pay|ssl|www|new|alpha)\.reddit\.com|libredd\.it|teddit\.net)\/(r|u)\/", flags=re.A)
color_regex = re.compile("[a-f0-9]{6}", flags=re.A)