forked from rDrama/rDrama
commit
9c658c23b0
|
@ -860,8 +860,28 @@ def submit_post(v):
|
||||||
body += "\n\n---\n\n"
|
body += "\n\n---\n\n"
|
||||||
else: body = ""
|
else: body = ""
|
||||||
if new_post.url:
|
if new_post.url:
|
||||||
body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={quote(new_post.url)}&run=1) (click to archive)"
|
body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={quote(new_post.url)}&run=1) (click to archive)\n\n"
|
||||||
gevent.spawn(archiveorg, new_post.url)
|
gevent.spawn(archiveorg, new_post.url)
|
||||||
|
|
||||||
|
# archive other urls in post
|
||||||
|
url_regex = '<a (target=\"_blank\" )?(rel=\"nofollow noopener noreferrer\" )?href=\"(https?://[a-z]{1,20}\.[^\"]+)\"( rel=\"nofollow noopener noreferrer\" target=\"_blank\")?>([^\"]+)</a>'
|
||||||
|
_body = new_post.body_html
|
||||||
|
#print(_body)
|
||||||
|
for url_match in re.finditer(url_regex, _body, flags=re.M|re.I):
|
||||||
|
href = url_match.group(3)
|
||||||
|
|
||||||
|
if not href:
|
||||||
|
#print(f'{url_match.group(0)} skip')
|
||||||
|
continue
|
||||||
|
|
||||||
|
#print(href)
|
||||||
|
title = url_match.group(5)
|
||||||
|
body += f'**[{title}]({href})**:\n\n'
|
||||||
|
body += f'* [reveddit.com](https://reveddit.com/{href})\n'
|
||||||
|
body += f'* [archive.org](https://web.archive.org/{href})\n'
|
||||||
|
body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n'
|
||||||
|
gevent.spawn(archiveorg, href)
|
||||||
|
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
body_html = sanitize(body_md)
|
body_html = sanitize(body_md)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue