Add support for Nginx streaming (See docs)

This commit is contained in:
pluja 2020-09-10 09:27:31 +02:00
parent cea9b63eca
commit d01e418c2f
3 changed files with 12 additions and 2 deletions

View File

@ -320,7 +320,10 @@ def channel(id):
def watch():
id = request.args.get('v', None)
info = ytvids.get_video_info(id)
video = {
hostName = urllib.parse.urlparse(info['video']['url']).netloc
# Use nginx
url = info['video']['url'].replace(hostName, "yotter.xyz")+"&hostname="+hostName
video={
'title':info['video']['title'],
'description':Markup(markupString(info['video']['description'])),
'viewCount':info['video']['views'],
@ -329,7 +332,9 @@ def watch():
'channelId': info['owner']['id'],
'id':id,
'averageRating': str((float(info['video']['rating'])/5)*100),
'nginxUrl': url,
'videoUrl': info['video']['url'],
'videoHostName': hostName,
'isLive': info['video']['isLive'],
'isUpcoming': info['video']['isUpcoming'],
'thumbnail': info['video']['thumbnail']

View File

@ -11,7 +11,11 @@
controls
buffered
preload="none">
<source src="{{url_for('stream', url=video.videoUrl.replace('/', 'YotterSlash'))}}" type="video/mp4">
{% if config.nginxVideoStream %}
<source src="{{video.nginxUrl}}" type="video/mp4">
{% else %}
<source src="{{url_for('stream', url=video.videoUrl.replace('/', 'YotterSlash'))}}" type="video/mp4">
{% endif %}
</video>
</div>

View File

@ -4,6 +4,7 @@
"maxInstanceUsers": 30,
"serverLocation": "Germany",
"restrictPublicUsage":true,
"nginxVideoStream":false,
"maintenance_mode":false,
"show_admin_message":false,
"admin_message_title":"Message from the admin",