forked from MarseyWorld/MarseyWorld
refactor nitter
parent
6b4e582f7e
commit
7edd569090
|
@ -21,8 +21,11 @@ def normalize_urls_runtime(body, v):
|
|||
|
||||
if v and v.reddit != 'old.reddit.com':
|
||||
body = reddit_to_vreddit_regex.sub(rf'\1https://{v.reddit}/\2/', body)
|
||||
if v.nitter: body = twitter_to_nitter_regex.sub(r'https://nitter.42l.fr/\1', body)
|
||||
if v.imginn: body = body.replace('https://instagram.com/', 'https://imginn.com/')
|
||||
if v.nitter:
|
||||
body = body.replace('https://twitter.com/', 'https://nitter.42l.fr/')
|
||||
body = body.replace('https://nitter.42l.fr/i/', 'https://twitter.com/i/')
|
||||
if v.imginn:
|
||||
body = body.replace('https://instagram.com/', 'https://imginn.com/')
|
||||
|
||||
return body
|
||||
|
||||
|
|
|
@ -90,8 +90,6 @@ greentext_regex = re.compile("(\n|^)>([^ >][^\n]*)", flags=re.A)
|
|||
|
||||
ascii_only_regex = re.compile("[ -~]+", flags=re.A)
|
||||
|
||||
twitter_to_nitter_regex = re.compile("https:\/\/twitter.com\/(\w{2,15}(\/status\/\d+[^/]*)?)", flags=re.A)
|
||||
|
||||
reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|u)\/', flags=re.A)
|
||||
|
||||
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|new\.reddit.com|www\.reddit.com|i\.reddit\.com|libredd\.it|teddit\.net)\/(r|u)\/", flags=re.A)
|
||||
|
|
Loading…
Reference in New Issue