forked from rDrama/rDrama
1
0
Fork 0

use search-new + unify reddit profile url

master
Aevann 2023-09-18 21:26:21 +03:00
parent 03e9c5bc1e
commit 1eabaca2c1
5 changed files with 12 additions and 4 deletions

View File

@ -158,6 +158,9 @@ def execute_snappy(post, v):
if post.url.startswith('https://old.reddit.com/r/'):
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/"):
rev = post.url.replace('https://old.reddit.com/user/', '')
rev = f"* [search-new.pullpush.io](https://search-new.pullpush.io/?author={rev}&type=submission)\n\n"
else: rev = ''
body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{post.url})\n\n* [ghostarchive.org](https://ghostarchive.org/search?term={quote(post.url)})\n\n* [archive.ph](https://archive.ph/?url={quote(post.url)}&run=1) (click to archive)\n\n"
@ -182,6 +185,9 @@ def execute_snappy(post, v):
if href.startswith('https://old.reddit.com/r/'):
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/'):
rev = href.replace('https://old.reddit.com/user/', '')
addition += f"* [search-new.pullpush.io](https://search-new.pullpush.io/?author={rev}&type=submission)\n\n"
addition += f'* [archive.org](https://web.archive.org/{href})\n\n'
addition += f'* [ghostarchive.org](https://ghostarchive.org/search?term={quote(href)})\n\n'
addition += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n'

View File

@ -75,7 +75,7 @@ def notify_mentions(mentions, send_to=None, mention_str='site mention'):
permalink = m['permalink']
text = sanitize(m['text'], blackjack="reddit mention", golden=False)
notif_text = (
f'<p>New {mention_str} by <a href="https://old.reddit.com/u/{author}" '
f'<p>New {mention_str} by <a href="https://old.reddit.com/user/{author}" '
f'rel="nofollow noopener" target="_blank">/u/{author}</a></p>'
f'<p><a href="https://old.reddit.com{permalink}?context=89" '
'rel="nofollow noopener" target="_blank">'

View File

@ -246,14 +246,14 @@ asset_image_link_regex = re.compile(f"https:\/\/(i\.)?{SITE}\/assets\/images\/[\
#sanitizing
reddit_mention_regex = re.compile('(?<![\w/])\/?(([ruRU])\/[\w-]{2,25})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2})(?:-[A-z]{2})" "?|www|new)\.reddit\.com|libredd\.it|reddit\.lol)\/(u\/|user\/|(r\/\w{2,25}\/)?comments\/|r\/\w{2,25}\/?$)", flags=re.A)
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2})(?:-[A-z]{2})" "?|www|new)\.reddit\.com|libredd\.it|reddit\.lol)\/(user\/|(r\/\w{2,25}\/)?comments\/|r\/\w{2,25}\/?$)", flags=re.A)
reddit_comment_link_regex = re.compile("https:\/\/old.reddit.com\/r\/\w{2,25}\/comments(\/\w+){3}\/?", flags=re.A)
#gevent
reddit_s_url_regex = re.compile("https:\/\/reddit.com\/[ru]\/\w{2,25}\/s\/\w{10}", flags=re.A)
#run-time
reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|u|user)\/', flags=re.A)
reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|user)\/', flags=re.A)

View File

@ -745,6 +745,8 @@ def is_whitelisted(domain, k):
def normalize_url(url):
url = unquote(url)
url = url.replace("reddit.com/u/", "reddit.com/user/")
url = reddit_domain_regex.sub(r'\1https://old.reddit.com/\3', url)
url = url.replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=") \

View File

@ -242,7 +242,7 @@ Text 2
<tr>
<td>Redditor Mention</td>
<td>u/Bardfinn</td>
<td><a class="d-inline-block" rel="nofollow noopener" href="https://old.reddit.com/u/Bardfinn">u/Bardfinn</a></td>
<td><a class="d-inline-block" rel="nofollow noopener" href="https://old.reddit.com/user/Bardfinn">u/Bardfinn</a></td>
</tr>
<tr>
<td>Ping Group Mention<br>