forked from rDrama/rDrama
remove unecessary request when making a post linking to a yt video
parent
b5aefda124
commit
0be653e632
|
@ -712,17 +712,15 @@ def submit_post(v, sub=None):
|
||||||
yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0].split('%')[0]
|
yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0].split('%')[0]
|
||||||
|
|
||||||
if yt_id_regex.fullmatch(yt_id):
|
if yt_id_regex.fullmatch(yt_id):
|
||||||
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={yt_id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json()
|
params = parse_qs(urlparse(url).query, keep_blank_values=True)
|
||||||
if req.get('items'):
|
t = params.get('t', params.get('start', [0]))[0]
|
||||||
params = parse_qs(urlparse(url).query, keep_blank_values=True)
|
if isinstance(t, str): t = t.replace('s','')
|
||||||
t = params.get('t', params.get('start', [0]))[0]
|
|
||||||
if isinstance(t, str): t = t.replace('s','')
|
|
||||||
|
|
||||||
embed = f'<lite-youtube videoid="{yt_id}" params="autoplay=1&modestbranding=1'
|
embed = f'<lite-youtube videoid="{yt_id}" params="autoplay=1&modestbranding=1'
|
||||||
if t:
|
if t:
|
||||||
try: embed += f'&start={int(t)}'
|
try: embed += f'&start={int(t)}'
|
||||||
except: pass
|
except: pass
|
||||||
embed += '"></lite-youtube>'
|
embed += '"></lite-youtube>'
|
||||||
|
|
||||||
elif SITE in domain and "/post/" in url and "context" not in url and url.count('/') < 6:
|
elif SITE in domain and "/post/" in url and "context" not in url and url.count('/') < 6:
|
||||||
id = url.split("/post/")[1]
|
id = url.split("/post/")[1]
|
||||||
|
|
Loading…
Reference in New Issue