Use template for direct MP4 link

This commit is contained in:
Dylan 2022-09-20 01:39:21 +01:00
parent 7e7530b90c
commit 9981a2deb0
2 changed files with 22 additions and 6 deletions

16
templates/rawvideo.html Normal file
View File

@ -0,0 +1,16 @@
{% extends 'base.html' %} {% block head %}
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
<meta name="twitter:player:stream" content="{{ vidurl }}" />
<meta name="twitter:player:stream:content_type" content="video/mp4" />
<meta name="twitter:player:width" content="{{ videoSize['width'] }}" />
<meta name="twitter:player:height" content="{{ videoSize['height'] }}" />
<meta property="og:url" content="{{ vidurl }}" />
<meta property="og:video" content="{{ vidurl }}" />
<meta property="og:video:secure_url" content="{{ vidurl }}" />
<meta property="og:video:type" content="video/mp4" />
<meta property="og:video:width" content="{{ videoSize['width'] }}" />
<meta property="og:video:height" content="{{ videoSize['height'] }}" />
<meta name="twitter:card" content="player" />
<meta http-equiv="refresh" content="0; url = {{ vidurl }}" /> {% endblock %} {% block body %} Redirecting you to the video in a moment. <a href="{{ vidurl }}">Or click here.</a> {% endblock %}

View File

@ -67,9 +67,9 @@ def twitfix(sub_path):
clean = twitter_url[:-4]
else:
clean = twitter_url
#vid = requests.get(direct_video_link(clean))
#return Response(vid.content,mimetype="video/mp4") keeping this here in case Discord changes their mind & blocks 307's
return redirect(direct_video_link(clean),code=307) # Discord, why do you fail to play 301/302 redirected URLS with .mp4 at the end???
vnf = vnfFromCacheOrDL(clean)
return getTemplate("rawvideo.html",vnf,"","",clean,"","","","")
else:
return message("To use a direct MP4 link in discord, remove anything past '?' and put '.mp4' at the end")
else:
@ -93,9 +93,9 @@ def twitfix(sub_path):
clean = twitter_url[:-4]
else:
clean = twitter_url
# TODO: Cache this, but not for too long as disk space can fill up
vid = requests.get(direct_video_link(clean))
return Response(vid.content,mimetype="video/mp4")
vnf = vnfFromCacheOrDL(clean)
return getTemplate("rawvideo.html",vnf,"","",clean,"","","","")
elif request.url.endswith("/1") or request.url.endswith("/2") or request.url.endswith("/3") or request.url.endswith("/4") or request.url.endswith("%2F1") or request.url.endswith("%2F2") or request.url.endswith("%2F3") or request.url.endswith("%2F4"):
twitter_url = "https://twitter.com/" + sub_path