no need to use regex

master
Aevann 2023-10-27 00:53:16 +03:00
parent e29b0f37ee
commit e84f42d34a
2 changed files with 2 additions and 4 deletions

View File

@ -168,7 +168,7 @@ def execute_snappy(post, v):
body += "\n\n"
if post.url and not post.url.startswith('/') and not post.url.startswith(f'{SITE_FULL}/') and not post.url.startswith(SITE_FULL_IMAGES):
if reddit_post_permalink_regex.fullmatch(post.url):
if post.url.startswith('https://old.reddit.com/r/') and '/comments/' in post.url:
rev = post.url.replace('https://old.reddit.com/', '')
rev = f"* [undelete.pullpush.io](https://undelete.pullpush.io/{rev})\n\n"
elif post.url.startswith("https://old.reddit.com/user/"):
@ -196,7 +196,7 @@ def execute_snappy(post, v):
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
if f'**[{title}]({href})**:\n\n' not in body:
addition = f'**[{title}]({href})**:\n\n'
if reddit_post_permalink_regex.fullmatch(href):
if href.startswith('https://old.reddit.com/r/') and '/comments/' in href:
rev = href.replace('https://old.reddit.com/', '')
addition += f'* [undelete.pullpush.io](https://undelete.pullpush.io/{rev})\n\n'
elif href.startswith('https://old.reddit.com/user/'):

View File

@ -248,8 +248,6 @@ reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/([ru])\/'
#post search
subreddit_name_regex = re.compile('\w{2,25}', flags=re.A)
#undelete.pullpush.io
reddit_post_permalink_regex = re.compile('https:\/\/old.reddit.com\/r\/\w{2,25}\/comments\/.*', flags=re.A)
###YOUTUBE