Testing support for livestreams
This commit is contained in:
parent
6219fa5f9d
commit
74a3651faf
@ -300,7 +300,6 @@ def ytsearch():
|
|||||||
channel['thumbnail'] = channel['thumbnail'].replace("~", "/")
|
channel['thumbnail'] = channel['thumbnail'].replace("~", "/")
|
||||||
hostName = urllib.parse.urlparse(channel['thumbnail']).netloc
|
hostName = urllib.parse.urlparse(channel['thumbnail']).netloc
|
||||||
channel['thumbnail'] = channel['thumbnail'].replace("https://{}".format(hostName), "")+"?host="+hostName
|
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)
|
return render_template('ytsearch.html', form=form, btform=button_form, results=results, restricted=config['restrictPublicUsage'], config=config, npage=next_page, ppage=prev_page)
|
||||||
else:
|
else:
|
||||||
return render_template('ytsearch.html', form=form, results=False)
|
return render_template('ytsearch.html', form=form, results=False)
|
||||||
@ -373,7 +372,6 @@ def channel(id):
|
|||||||
channelData = YoutubeSearch.channelInfo(id)
|
channelData = YoutubeSearch.channelInfo(id)
|
||||||
|
|
||||||
for video in channelData[1]:
|
for video in channelData[1]:
|
||||||
print(video)
|
|
||||||
if config['nginxVideoStream']:
|
if config['nginxVideoStream']:
|
||||||
hostName = urllib.parse.urlparse(video['videoThumb']).netloc
|
hostName = urllib.parse.urlparse(video['videoThumb']).netloc
|
||||||
video['videoThumb'] = video['videoThumb'].replace("https://{}".format(hostName), "").replace("hqdefault", "mqdefault")+"&host="+hostName
|
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)
|
best_urls.append(url)
|
||||||
return best_urls
|
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'])
|
@app.route('/watch', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def watch():
|
def watch():
|
||||||
@ -421,6 +429,9 @@ def watch():
|
|||||||
vid_urls=[]
|
vid_urls=[]
|
||||||
else:
|
else:
|
||||||
vid_urls = get_best_urls(info['video']['urls'])
|
vid_urls = get_best_urls(info['video']['urls'])
|
||||||
|
|
||||||
|
if info['video']['isLive']:
|
||||||
|
vid_urls = get_live_urls(info['video']['urls'])
|
||||||
|
|
||||||
video={
|
video={
|
||||||
'title':info['video']['title'],
|
'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" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="ui text container">
|
<div class="ui text container">
|
||||||
{% if video.nginxUrl == "#" and video.isLive %}
|
{% if video.nginxUrl == "#" %}
|
||||||
<div class="ui center aligned text container">
|
<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>
|
</div>
|
||||||
{% elif video.isUpcoming %}
|
{% elif video.isUpcoming %}
|
||||||
<div class="ui center aligned text container">
|
<div class="ui center aligned text container">
|
||||||
@ -16,10 +18,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% elif video.isLive %}
|
{% 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 center aligned text container">
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<h4 class="ui header">LIVESTREAM VIDEO</h4>
|
<h3 class="ui header">LIVESTREAM VIDEO</h3>
|
||||||
<h5 class="ui header">Livestreams are still not supported on Yotter.</h5>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{%else%}
|
{%else%}
|
||||||
@ -81,4 +91,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="{{ url_for('static',filename='video.min.js') }}"></script>
|
<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 %}
|
{% endblock %}
|
Reference in New Issue
Block a user