yt timestamps
This commit is contained in:
parent
bcfab960a4
commit
6b95a798d0
3 changed files with 5 additions and 5 deletions
|
@ -201,8 +201,10 @@ 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}" 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)
|
||||||
htmlsource = f'<iframe class="embedvid" loading="lazy" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
htmlsource = f'<iframe class="embedvid" loading="lazy" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
||||||
sanitized = sanitized.replace(replacing, htmlsource.replace("watch?v=", "embed/"))
|
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):
|
||||||
url = i.group(1)
|
url = i.group(1)
|
||||||
|
|
|
@ -38,10 +38,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
comment = get_comment(cid, v=v)
|
comment = get_comment(cid, v=v)
|
||||||
|
|
||||||
if v and request.values.get("read"):
|
if v and request.values.get("read"):
|
||||||
print(1)
|
|
||||||
notif = g.db.query(Notification).options(lazyload('*')).filter_by(comment_id=cid, user_id=v.id, read=False).first()
|
notif = g.db.query(Notification).options(lazyload('*')).filter_by(comment_id=cid, user_id=v.id, read=False).first()
|
||||||
if notif:
|
if notif:
|
||||||
print(2)
|
|
||||||
notif.read = True
|
notif.read = True
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
|
@ -552,7 +552,7 @@ def submit_post(v):
|
||||||
try:
|
try:
|
||||||
yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2)
|
yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2)
|
||||||
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].replace('s','')
|
||||||
if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
|
if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
|
||||||
else: embed = f"https://youtube.com/embed/{yt_id}"
|
else: embed = f"https://youtube.com/embed/{yt_id}"
|
||||||
except: embed = None
|
except: embed = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue