forked from rDrama/rDrama
fdsfsd
parent
0e2e5a3700
commit
38b82ad701
|
@ -148,8 +148,6 @@ if SITE == 'rdrama.net':
|
||||||
LLM_ID = 253
|
LLM_ID = 253
|
||||||
DAD_ID = 2513
|
DAD_ID = 2513
|
||||||
MOM_ID = 4588
|
MOM_ID = 4588
|
||||||
BUG_THREAD = 18459
|
|
||||||
EMOJI_THREAD = 22479
|
|
||||||
elif SITE == "pcmemes.net":
|
elif SITE == "pcmemes.net":
|
||||||
BASEDBOT_ID = 800
|
BASEDBOT_ID = 800
|
||||||
KIPPY_ID = 1592
|
KIPPY_ID = 1592
|
||||||
|
@ -170,8 +168,6 @@ elif SITE == "pcmemes.net":
|
||||||
LLM_ID = 0
|
LLM_ID = 0
|
||||||
DAD_ID = 0
|
DAD_ID = 0
|
||||||
MOM_ID = 0
|
MOM_ID = 0
|
||||||
BUG_THREAD = 4103
|
|
||||||
EMOJI_THREAD = 0
|
|
||||||
else:
|
else:
|
||||||
BASEDBOT_ID = 0
|
BASEDBOT_ID = 0
|
||||||
KIPPY_ID = 0
|
KIPPY_ID = 0
|
||||||
|
@ -192,8 +188,6 @@ else:
|
||||||
LLM_ID = 0
|
LLM_ID = 0
|
||||||
DAD_ID = 0
|
DAD_ID = 0
|
||||||
MOM_ID = 0
|
MOM_ID = 0
|
||||||
BUG_THREAD = 0
|
|
||||||
EMOJI_THREAD = 0
|
|
||||||
|
|
||||||
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
|
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
|
||||||
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
||||||
|
|
|
@ -210,12 +210,21 @@ def sanitize(sanitized, noimages=False):
|
||||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
||||||
|
|
||||||
|
|
||||||
for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=.*?)</a>', sanitized):
|
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
||||||
|
|
||||||
|
for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))</a>', sanitized):
|
||||||
url = i.group(1)
|
url = i.group(1)
|
||||||
|
yt_id = i.group(2).split('&')[0]
|
||||||
replacing = f'<a href="{url}" rel="nofollow noopener noreferrer" target="_blank">{url}</a>'
|
replacing = f'<a href="{url}" rel="nofollow noopener noreferrer" target="_blank">{url}</a>'
|
||||||
url = url.replace("watch?v=", "embed/").replace("&t", "?start").replace("?t", "?start")
|
|
||||||
url = re.sub('(\?start=([0-9]*?))s', r'\1', url)
|
params = parse_qs(urlparse(url).query)
|
||||||
htmlsource = f'<iframe class="embedvid" loading="lazy" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
t = params.get('t', params.get('start', [0]))[0]
|
||||||
|
if isinstance(t, str): t = t.replace('s','')
|
||||||
|
|
||||||
|
htmlsource = f'<lite-youtube videoid="{yt_id}" params="controls=0&modestbranding=1'
|
||||||
|
if t: htmlsource += f'&start={t}'
|
||||||
|
htmlsource += '"></lite-youtube>'
|
||||||
|
|
||||||
sanitized = sanitized.replace(replacing, htmlsource)
|
sanitized = sanitized.replace(replacing, htmlsource)
|
||||||
|
|
||||||
for i in re.finditer('<a href="(https://streamable\.com/e/.*?)"', sanitized):
|
for i in re.finditer('<a href="(https://streamable\.com/e/.*?)"', sanitized):
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -101,8 +101,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
try: pid = int(pid)
|
try: pid = int(pid)
|
||||||
except Exception as e: pass
|
except Exception as e: pass
|
||||||
|
|
||||||
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new'
|
if v: defaultsortingcomments = v.defaultsortingcomments
|
||||||
elif v: defaultsortingcomments = v.defaultsortingcomments
|
|
||||||
else: defaultsortingcomments = "top"
|
else: defaultsortingcomments = "top"
|
||||||
|
|
||||||
sort = request.values.get("sort", defaultsortingcomments)
|
sort = request.values.get("sort", defaultsortingcomments)
|
||||||
|
@ -116,8 +115,6 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
if post.club and not (v and (v.paid_dues or v.id == post.author_id)) or post.private and not (v and v.id == post.author_id): abort(403)
|
if post.club and not (v and (v.paid_dues or v.id == post.author_id)) or post.private and not (v and v.id == post.author_id): abort(403)
|
||||||
|
|
||||||
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
|
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
|
@ -135,7 +132,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
|
if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
|
||||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.is_pinned == None).join(
|
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
isouter=True
|
isouter=True
|
||||||
|
@ -157,7 +154,9 @@ def post_id(pid, anything=None, v=None):
|
||||||
comment.is_blocked = c[3] or 0
|
comment.is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
comments = comments.filter(Comment.level == 1)
|
pinned = [c[0] for c in comments.filter(Comment.is_pinned != None).all()]
|
||||||
|
|
||||||
|
comments = comments.filter(Comment.level == 1, Comment.is_pinned == None)
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
comments = comments.order_by(Comment.created_utc.desc())
|
comments = comments.order_by(Comment.created_utc.desc())
|
||||||
|
@ -175,6 +174,8 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
comments = [c[0] for c in comments.all()]
|
comments = [c[0] for c in comments.all()]
|
||||||
else:
|
else:
|
||||||
|
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
|
||||||
|
|
||||||
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None)
|
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None)
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
|
@ -207,8 +208,6 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
post.replies = pinned + comments
|
post.replies = pinned + comments
|
||||||
|
|
||||||
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD] and not request.values.get("sort"): post.replies = post.replies[:10]
|
|
||||||
|
|
||||||
post.views += 1
|
post.views += 1
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0
|
if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0
|
||||||
|
@ -638,8 +637,10 @@ def submit_post(v):
|
||||||
params = parse_qs(urlparse(url).query)
|
params = parse_qs(urlparse(url).query)
|
||||||
t = params.get('t', params.get('start', [0]))[0]
|
t = params.get('t', params.get('start', [0]))[0]
|
||||||
if isinstance(t, str): t = t.replace('s','')
|
if isinstance(t, str): t = t.replace('s','')
|
||||||
if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
|
embed = f'<lite-youtube videoid="{yt_id}" params="controls=0&modestbranding=1'
|
||||||
else: embed = f"https://youtube.com/embed/{yt_id}"
|
if t: embed += f'&start={t}'
|
||||||
|
embed += '"></lite-youtube>'
|
||||||
|
|
||||||
elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url:
|
elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url:
|
||||||
id = url.split("/post/")[1]
|
id = url.split("/post/")[1]
|
||||||
if "/" in id: id = id.split("/")[0]
|
if "/" in id: id = id.split("/")[0]
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{p.embed_url | safe}}
|
|
||||||
<script src="/assets/js/twitter.js" charset="utf-8">
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
|
|
||||||
</script>
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{p.embed_url | safe}}
|
|
||||||
<script src="https://platform.twitter.com/widgets.js" charset="utf-8">
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
|
|
||||||
</script>
|
|
|
@ -1,3 +0,0 @@
|
||||||
<div class="embed-responsive embed-responsive-16by9 mb-3">
|
|
||||||
<iframe loading="lazy" src="{{p.embed_url}}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
||||||
</div>
|
|
|
@ -84,7 +84,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/js/emoji_modal.js?v=128"></script>
|
<script src="/assets/js/emoji_modal.js?v=129"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
a.emojitab {
|
a.emojitab {
|
||||||
|
|
|
@ -473,12 +473,22 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if p.embed_url %}
|
{% if p.embed_url %}
|
||||||
{% if p.domain == "twitter.com" and (v and v.theme.split("_")[0] in ["light", "coffee", "4chan"]) %}
|
{% if p.domain == "twitter.com" %}
|
||||||
{% include "embeds/twitterlight.html" %}
|
{{p.embed_url | safe}}
|
||||||
{% elif "twitter.com" in p.domain %}
|
{% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %}
|
||||||
{% include "embeds/twitter.html" %}
|
<script src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
||||||
|
{% else %}
|
||||||
|
<script src="/assets/js/twitter.js" charset="utf-8"></script>
|
||||||
|
{% endif %}
|
||||||
|
<script>document.getElementById('twitter-widget-0').setAttribute('sandbox','')</script>
|
||||||
{% elif "youtu" in p.domain %}
|
{% elif "youtu" in p.domain %}
|
||||||
{% include "embeds/youtube.html" %}
|
{% if 'lite' in p.embed_url %}
|
||||||
|
{{p.embed_url | safe}}
|
||||||
|
{% else %}
|
||||||
|
<div class="embed-responsive embed-responsive-16by9 mb-3">
|
||||||
|
<iframe loading="lazy" src="{{p.embed_url}}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -492,7 +492,11 @@
|
||||||
</div>
|
</div>
|
||||||
{% elif p.embed_url and "youtu" in p.domain %}
|
{% elif p.embed_url and "youtu" in p.domain %}
|
||||||
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-3 mb-4">
|
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-3 mb-4">
|
||||||
|
{% if 'lite' in p.embed_url %}
|
||||||
|
{{p.embed_url | safe}}
|
||||||
|
{% else %}
|
||||||
<iframe loading="lazy" src="{{p.embed_url}}" frameborder="0" style="max-width:100%;max-height:20rem" width="600" height="337" allow="fullscreen"></iframe>
|
<iframe loading="lazy" src="{{p.embed_url}}" frameborder="0" style="max-width:100%;max-height:20rem" width="600" height="337" allow="fullscreen"></iframe>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% elif p.url and "streamable.com/e/" in p.url %}
|
{% elif p.url and "streamable.com/e/" in p.url %}
|
||||||
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-3 mb-4">
|
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-3 mb-4">
|
||||||
|
|
Loading…
Reference in New Issue