Testing support for livestreams
This commit is contained in:
parent
6219fa5f9d
commit
74a3651faf
@ -300,7 +300,6 @@ def ytsearch():
|
||||
channel['thumbnail'] = channel['thumbnail'].replace("~", "/")
|
||||
hostName = urllib.parse.urlparse(channel['thumbnail']).netloc
|
||||
channel['thumbnail'] = channel['thumbnail'].replace("https://{}".format(hostName), "")+"?host="+hostName
|
||||
print(channel['thumbnail'])
|
||||
return render_template('ytsearch.html', form=form, btform=button_form, results=results, restricted=config['restrictPublicUsage'], config=config, npage=next_page, ppage=prev_page)
|
||||
else:
|
||||
return render_template('ytsearch.html', form=form, results=False)
|
||||
@ -373,7 +372,6 @@ def channel(id):
|
||||
channelData = YoutubeSearch.channelInfo(id)
|
||||
|
||||
for video in channelData[1]:
|
||||
print(video)
|
||||
if config['nginxVideoStream']:
|
||||
hostName = urllib.parse.urlparse(video['videoThumb']).netloc
|
||||
video['videoThumb'] = video['videoThumb'].replace("https://{}".format(hostName), "").replace("hqdefault", "mqdefault")+"&host="+hostName
|
||||
@ -397,6 +395,16 @@ def get_best_urls(urls):
|
||||
best_urls.append(url)
|
||||
return best_urls
|
||||
|
||||
def get_live_urls(urls):
|
||||
'''Gets URLS in youtube format (format_id, url, height) and returns best ones for yotter'''
|
||||
best_formats = ["91", "92", "93", "94", "95", "96"]
|
||||
best_urls=[]
|
||||
for url in urls:
|
||||
for f in best_formats:
|
||||
if url['format_id'] == f:
|
||||
best_urls.append(url)
|
||||
return best_urls
|
||||
|
||||
@app.route('/watch', methods=['GET'])
|
||||
@login_required
|
||||
def watch():
|
||||
@ -421,6 +429,9 @@ def watch():
|
||||
vid_urls=[]
|
||||
else:
|
||||
vid_urls = get_best_urls(info['video']['urls'])
|
||||
|
||||
if info['video']['isLive']:
|
||||
vid_urls = get_live_urls(info['video']['urls'])
|
||||
|
||||
video={
|
||||
'title':info['video']['title'],
|
||||
|
7
app/static/videojs-http-streaming.min.js
vendored
Normal file
7
app/static/videojs-http-streaming.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -4,9 +4,11 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="ui text container">
|
||||
{% if video.nginxUrl == "#" and video.isLive %}
|
||||
{% if video.nginxUrl == "#" %}
|
||||
<div class="ui center aligned text container">
|
||||
<img alt="Empty feed image" class="ui image" src="{{ url_for('static',filename='img/live.png') }}">
|
||||
<div class="ui segment">
|
||||
<h4 class="ui header">ERROR WITH VIDEO</h4>
|
||||
</div>
|
||||
</div>
|
||||
{% elif video.isUpcoming %}
|
||||
<div class="ui center aligned text container">
|
||||
@ -16,10 +18,18 @@
|
||||
</div>
|
||||
</div>
|
||||
{% elif video.isLive %}
|
||||
<div class="video-js-responsive-container vjs-hd">
|
||||
<video-js id=live width="1080" class="video-js vjs-default-skin" controls buffered>
|
||||
<source
|
||||
src="{{urls[0]['url']}}"
|
||||
type="application/x-mpegURL">
|
||||
</video-js>
|
||||
</div>
|
||||
<div class="ui center aligned text container">
|
||||
<div class="ui segment">
|
||||
<h4 class="ui header">LIVESTREAM VIDEO</h4>
|
||||
<h5 class="ui header">Livestreams are still not supported on Yotter.</h5>
|
||||
<h3 class="ui header">LIVESTREAM VIDEO</h3>
|
||||
<h4 class="ui header">FEATURE AVAILABLE SOON</h4>
|
||||
<h5 class="ui header">Livestreams are under developent and still not supported on Yotter.</h5>
|
||||
</div>
|
||||
</div>
|
||||
{%else%}
|
||||
@ -81,4 +91,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="{{ url_for('static',filename='video.min.js') }}"></script>
|
||||
<script src="{{ url_for('static',filename='videojs-http-streaming.min.js')}}"></script>
|
||||
<script>
|
||||
var player = videojs('live');
|
||||
player.play();
|
||||
</script>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user