From 3b1e507c475c8b44ff389bf30ed2eea1ae123a0e Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 2 Mar 2024 01:04:13 +0200 Subject: [PATCH] fix this https://rdrama.net/h/slackernews/post/250030/nintendo-yuzu-lolsuit-was-kicked-off/6035221#context --- files/helpers/actions.py | 37 ++++++++++++++------------- files/helpers/config/boosted_sites.py | 3 +++ files/helpers/sanitize.py | 6 +---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 33cfe44d0..6846d3e32 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -51,6 +51,23 @@ def snappy_report(post, reason): message = f'@Snappy reported {post.textlink})\n\n> {reason}' send_repeatable_notification(post.author_id, message) +def get_archival_urls(href): + addition = '' + 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" + elif href.startswith('https://boards.4chan.org/'): + rev = href.replace('https://boards.4chan.org/', '') + addition += f'* [archived.moe](https://archived.moe/{rev})\n\n' + + addition += f'* [ghostarchive.org](https://ghostarchive.org/search?term={quote(href)})\n\n' + addition += f'* [archive.org](https://web.archive.org/{href})\n\n' + addition += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n' + return addition + def execute_snappy(post, v): if post.hole and g.db.query(Exile.user_id).filter_by(user_id=SNAPPY_ID, hole=post.hole).one_or_none(): return @@ -194,15 +211,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 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}* [ghostarchive.org](https://ghostarchive.org/search?term={quote(post.url)})\n\n* [archive.org](https://web.archive.org/{post.url})\n\n* [archive.ph](https://archive.ph/?url={quote(post.url)}&run=1) (click to archive)\n\n" + body += f"Snapshots:\n\n{get_archival_urls(post.url)}" archive_url(post.url) captured = [] @@ -222,15 +231,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 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'* [ghostarchive.org](https://ghostarchive.org/search?term={quote(href)})\n\n' - addition += f'* [archive.org](https://web.archive.org/{href})\n\n' - addition += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n' + addition += get_archival_urls(href) if len(f'{body}{addition}') > COMMENT_BODY_LENGTH_LIMIT: break body += addition archive_url(href) diff --git a/files/helpers/config/boosted_sites.py b/files/helpers/config/boosted_sites.py index ace2cc3c4..3912fb8c2 100644 --- a/files/helpers/config/boosted_sites.py +++ b/files/helpers/config/boosted_sites.py @@ -7,6 +7,9 @@ BOOSTED_SITES = { #4chan-like #'all sites with the word "chan" in the domain', 'archived.moe', + 'desuarchive.org', + 'archive.4plebs.org', + 'arch.b4k.co', 'lolcow.farm', '8kun.top', 'soyjak.party', diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 62f895f48..ef3ee739c 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -742,11 +742,7 @@ domain_replacements = { 'https://letmegooglethat.com/?q=': 'https://google.com/search?q=', 'https://lmgtfy.app/?q=': 'https://google.com/search?q=', DONATE_LINK: f'{SITE_FULL}/donate', - 'https://boards.4chan.org/': 'https://archived.moe/', - 'https://boards.4channel.org/': 'https://archived.moe/', - 'https://desuarchive.org/': 'https://archived.moe/', - 'https://archive.4plebs.org/': 'https://archived.moe/', - 'https://arch.b4k.co/': 'https://archived.moe/', + 'https://boards.4channel.org/': 'https://boards.4chan.org/', } def normalize_url(url):