diff --git a/files/helpers/const.py b/files/helpers/const.py
index 14d33fb7da..7dbfff1c33 100644
--- a/files/helpers/const.py
+++ b/files/helpers/const.py
@@ -148,8 +148,6 @@ if SITE == 'rdrama.net':
LLM_ID = 253
DAD_ID = 2513
MOM_ID = 4588
- BUG_THREAD = 18459
- EMOJI_THREAD = 22479
elif SITE == "pcmemes.net":
BASEDBOT_ID = 800
KIPPY_ID = 1592
@@ -170,8 +168,6 @@ elif SITE == "pcmemes.net":
LLM_ID = 0
DAD_ID = 0
MOM_ID = 0
- BUG_THREAD = 4103
- EMOJI_THREAD = 0
else:
BASEDBOT_ID = 0
KIPPY_ID = 0
@@ -192,8 +188,6 @@ else:
LLM_ID = 0
DAD_ID = 0
MOM_ID = 0
- BUG_THREAD = 0
- EMOJI_THREAD = 0
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py
index 5a6efa8a5d..4d8df5f94e 100644
--- a/files/helpers/sanitize.py
+++ b/files/helpers/sanitize.py
@@ -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")
- for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=.*?)', 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\=(.*?))', sanitized):
url = i.group(1)
+ yt_id = i.group(2).split('&')[0]
replacing = f'{url}'
- url = url.replace("watch?v=", "embed/").replace("&t", "?start").replace("?t", "?start")
- url = re.sub('(\?start=([0-9]*?))s', r'\1', url)
- htmlsource = f''
+
+ params = parse_qs(urlparse(url).query)
+ t = params.get('t', params.get('start', [0]))[0]
+ if isinstance(t, str): t = t.replace('s','')
+
+ htmlsource = f''
+
sanitized = sanitized.replace(replacing, htmlsource)
for i in re.finditer('/")
diff --git a/files/routes/posts.py b/files/routes/posts.py
index 0e78ae53e6..975098b93a 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -101,8 +101,7 @@ def post_id(pid, anything=None, v=None):
try: pid = int(pid)
except Exception as e: pass
- if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new'
- elif v: defaultsortingcomments = v.defaultsortingcomments
+ if v: defaultsortingcomments = v.defaultsortingcomments
else: defaultsortingcomments = "top"
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)
- pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
-
if v:
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):
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.c.comment_id == Comment.id,
isouter=True
@@ -157,7 +154,9 @@ def post_id(pid, anything=None, v=None):
comment.is_blocked = c[3] or 0
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":
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()]
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)
if sort == "new":
@@ -207,8 +208,6 @@ def post_id(pid, anything=None, v=None):
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
g.db.add(post)
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)
t = params.get('t', params.get('start', [0]))[0]
if isinstance(t, str): t = t.replace('s','')
- if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
- else: embed = f"https://youtube.com/embed/{yt_id}"
+ embed = f''
+
elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url:
id = url.split("/post/")[1]
if "/" in id: id = id.split("/")[0]
diff --git a/files/templates/embeds/twitter.html b/files/templates/embeds/twitter.html
deleted file mode 100644
index 7c2ad7452c..0000000000
--- a/files/templates/embeds/twitter.html
+++ /dev/null
@@ -1,6 +0,0 @@
-{{p.embed_url | safe}}
-
-
\ No newline at end of file
diff --git a/files/templates/embeds/twitterlight.html b/files/templates/embeds/twitterlight.html
deleted file mode 100644
index 6ff688f772..0000000000
--- a/files/templates/embeds/twitterlight.html
+++ /dev/null
@@ -1,6 +0,0 @@
-{{p.embed_url | safe}}
-
-
\ No newline at end of file
diff --git a/files/templates/embeds/youtube.html b/files/templates/embeds/youtube.html
deleted file mode 100644
index 11f3b63e4b..0000000000
--- a/files/templates/embeds/youtube.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html
index 0aafe690a4..0f83a3f1a7 100644
--- a/files/templates/emoji_modal.html
+++ b/files/templates/emoji_modal.html
@@ -84,7 +84,7 @@
-
+