forked from rDrama/rDrama
dsfsfd
parent
e08b82dc17
commit
daf81b864d
|
@ -161,6 +161,7 @@ def sanitize(sanitized, noimages=False):
|
||||||
tag["style"] = "max-height: 100px; max-width: 100%;"
|
tag["style"] = "max-height: 100px; max-width: 100%;"
|
||||||
tag["class"] = "in-comment-image rounded-sm my-2"
|
tag["class"] = "in-comment-image rounded-sm my-2"
|
||||||
tag["loading"] = "lazy"
|
tag["loading"] = "lazy"
|
||||||
|
tag["data-src"] = tag["src"]
|
||||||
|
|
||||||
link = soup.new_tag("a")
|
link = soup.new_tag("a")
|
||||||
link["href"] = tag["src"]
|
link["href"] = tag["src"]
|
||||||
|
@ -171,6 +172,8 @@ def sanitize(sanitized, noimages=False):
|
||||||
link["data-bs-toggle"] = "modal"
|
link["data-bs-toggle"] = "modal"
|
||||||
link["data-bs-target"] = "#expandImageModal"
|
link["data-bs-target"] = "#expandImageModal"
|
||||||
|
|
||||||
|
tag["src"] = ""
|
||||||
|
|
||||||
tag.wrap(link)
|
tag.wrap(link)
|
||||||
|
|
||||||
#disguised link preventer
|
#disguised link preventer
|
||||||
|
@ -220,10 +223,10 @@ def sanitize(sanitized, noimages=False):
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
new = re.sub(f'\w*(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=60 src="https://{site}/assets/images/emojis/{emoji}.webp" style="transform: scaleX(-1)">', new)
|
new = re.sub(f'\w*(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=60 src="" data-src="https://{site}/assets/images/emojis/{emoji}.webp" style="transform: scaleX(-1)">', new)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
new = re.sub(f'\w*(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=60 src="https://{site}/assets/images/emojis/{emoji}.webp">', new)
|
new = re.sub(f'\w*(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=60 src="" data-src="https://{site}/assets/images/emojis/{emoji}.webp">', new)
|
||||||
|
|
||||||
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
|
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
|
||||||
else: session["favorite_emojis"][emoji] = 1
|
else: session["favorite_emojis"][emoji] = 1
|
||||||
|
@ -236,10 +239,10 @@ def sanitize(sanitized, noimages=False):
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'\w*(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 src="https://{site}/assets/images/emojis/{emoji}.webp" style="transform: scaleX(-1)">', sanitized)
|
sanitized = re.sub(f'\w*(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 src="" data-src="https://{site}/assets/images/emojis/{emoji}.webp" style="transform: scaleX(-1)">', sanitized)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'\w*(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized)
|
sanitized = re.sub(f'\w*(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 src="" data-src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized)
|
||||||
|
|
||||||
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
|
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
|
||||||
else: session["favorite_emojis"][emoji] = 1
|
else: session["favorite_emojis"][emoji] = 1
|
||||||
|
@ -251,22 +254,22 @@ def sanitize(sanitized, noimages=False):
|
||||||
for i in re.finditer('" target="_blank">(https://youtube.com/watch\?v\=.*?)</a>', sanitized):
|
for i in re.finditer('" target="_blank">(https://youtube.com/watch\?v\=.*?)</a>', sanitized):
|
||||||
url = i.group(1)
|
url = i.group(1)
|
||||||
replacing = f'<a href="{url}" target="_blank">{url}</a>'
|
replacing = f'<a href="{url}" target="_blank">{url}</a>'
|
||||||
htmlsource = f'<div class="embed-responsive embed-responsive-16by9 mb-3"><iframe loading="lazy" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>'
|
htmlsource = f'<div class="embed-responsive embed-responsive-16by9 mb-3"><iframe loading="lazy" src="" data-src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>'
|
||||||
sanitized = sanitized.replace(replacing, htmlsource.replace("watch?v=", "embed/"))
|
sanitized = sanitized.replace(replacing, htmlsource.replace("watch?v=", "embed/"))
|
||||||
|
|
||||||
for i in re.finditer('<a href="(https://streamable.com/e/.*?)"', sanitized):
|
for i in re.finditer('<a href="(https://streamable.com/e/.*?)"', sanitized):
|
||||||
url = i.group(1)
|
url = i.group(1)
|
||||||
replacing = f'<a href="{url}" target="_blank">{url}</a>'
|
replacing = f'<a href="{url}" target="_blank">{url}</a>'
|
||||||
htmlsource = f'<div class="embed-responsive embed-responsive-16by9 mb-3"><iframe loading="lazy" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>'
|
htmlsource = f'<div class="embed-responsive embed-responsive-16by9 mb-3"><iframe loading="lazy" src="" data-src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>'
|
||||||
sanitized = sanitized.replace(replacing, htmlsource)
|
sanitized = sanitized.replace(replacing, htmlsource)
|
||||||
|
|
||||||
for i in re.finditer('<p>(https:.*?\.mp4)</p>', sanitized):
|
for i in re.finditer('<p>(https:.*?\.mp4)</p>', sanitized):
|
||||||
sanitized = sanitized.replace(i.group(0), f'<p><video controls loop preload="metadata" style="max-width: 100%"><source src="{i.group(1)}" type="video/mp4"></video>')
|
sanitized = sanitized.replace(i.group(0), f'<p><video controls loop preload="metadata" style="max-width: 100%"><source src="" data-src="{i.group(1)}" type="video/mp4"></video>')
|
||||||
|
|
||||||
for i in re.finditer('<a href="(https://open.spotify.com/embed/.*?)"', sanitized):
|
for i in re.finditer('<a href="(https://open.spotify.com/embed/.*?)"', sanitized):
|
||||||
url = i.group(1)
|
url = i.group(1)
|
||||||
replacing = f'<a href="{url}" target="_blank">{url}</a>'
|
replacing = f'<a href="{url}" target="_blank">{url}</a>'
|
||||||
htmlsource = f'<iframe src="{url}" width="100%" height="80" frameBorder="0" allowtransparency="true" allow="encrypted-media"></iframe>'
|
htmlsource = f'<iframe src="" data-src="{url}" width="100%" height="80" frameBorder="0" allowtransparency="true" allow="encrypted-media"></iframe>'
|
||||||
sanitized = sanitized.replace(replacing, htmlsource)
|
sanitized = sanitized.replace(replacing, htmlsource)
|
||||||
|
|
||||||
for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]:
|
for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]:
|
||||||
|
|
Loading…
Reference in New Issue