forked from rDrama/rDrama
make snappy archive youtube videos too
parent
34089912c2
commit
bab105223b
|
@ -91,14 +91,21 @@ def execute_snappy(post, v):
|
||||||
|
|
||||||
captured = []
|
captured = []
|
||||||
body_for_snappy = post.body_html.replace(' data-src="', ' src="')
|
body_for_snappy = post.body_html.replace(' data-src="', ' src="')
|
||||||
|
|
||||||
|
|
||||||
for i in list(snappy_url_regex.finditer(body_for_snappy)):
|
for i in list(snappy_url_regex.finditer(body_for_snappy)):
|
||||||
if i.group(1) in captured: continue
|
|
||||||
captured.append(i.group(1))
|
|
||||||
|
|
||||||
href = i.group(1)
|
href = i.group(1)
|
||||||
if not href: continue
|
if href in [x[0] for x in captured]: continue
|
||||||
|
|
||||||
title = i.group(2)
|
title = i.group(2)
|
||||||
|
captured.append((href, title))
|
||||||
|
|
||||||
|
for i in list(snappy_youtube_regex.finditer(body_for_snappy)):
|
||||||
|
href = f'https://youtube.com/watch?v={i.group(1)}'
|
||||||
|
if href in [x[0] for x in captured]: continue
|
||||||
|
captured.append((href, href))
|
||||||
|
|
||||||
|
|
||||||
|
for href, title in captured:
|
||||||
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
|
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
|
||||||
|
|
||||||
if f'**[{title}]({href})**:\n\n' not in body:
|
if f'**[{title}]({href})**:\n\n' not in body:
|
||||||
|
|
|
@ -50,6 +50,7 @@ emoji_regex2 = re.compile(f'(?<!"):([!#@{valid_username_chars}]{{1,36}}?):', fla
|
||||||
emoji_regex3 = re.compile(f'(?<!"):([!@{valid_username_chars}]{{1,35}}?):', flags=re.A)
|
emoji_regex3 = re.compile(f'(?<!"):([!@{valid_username_chars}]{{1,35}}?):', flags=re.A)
|
||||||
|
|
||||||
snappy_url_regex = re.compile('<a href="(https?:\/\/.+?)".*?>(.+?)<\/a>', flags=re.A)
|
snappy_url_regex = re.compile('<a href="(https?:\/\/.+?)".*?>(.+?)<\/a>', flags=re.A)
|
||||||
|
snappy_youtube_regex = re.compile('<lite-youtube videoid="(.+?)" params="autoplay=1', flags=re.A)
|
||||||
|
|
||||||
email_regex = re.compile('[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}', flags=re.A|re.I)
|
email_regex = re.compile('[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}', flags=re.A|re.I)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue