Fix some videos not working
This commit is contained in:
parent
d028a2c343
commit
627e5e366f
@ -464,28 +464,38 @@ def get_live_urls(urls):
|
|||||||
def watch():
|
def watch():
|
||||||
id = request.args.get('v', None)
|
id = request.args.get('v', None)
|
||||||
info = ytwatch.extract_info(id, False, playlist_id=None, index=None)
|
info = ytwatch.extract_info(id, False, playlist_id=None, index=None)
|
||||||
# Use nginx
|
|
||||||
best_formats = ["22", "18", "34", "35", "36", "37", "38", "43", "44", "45", "46"]
|
vsources = ytwatch.get_video_sources(info, False)
|
||||||
|
# Retry 3 times if no sources are available.
|
||||||
|
retry = 3
|
||||||
|
while retry != 0 and len(vsources) == 0:
|
||||||
|
vsources = ytwatch.get_video_sources(info, False)
|
||||||
|
retry -= 1
|
||||||
|
|
||||||
|
for source in vsources:
|
||||||
|
hostName = urllib.parse.urlparse(source['src']).netloc
|
||||||
|
source['src'] = source['src'].replace("https://{}".format(hostName), "") + "?host=" + hostName
|
||||||
|
|
||||||
|
# Parse video formats
|
||||||
for v_format in info['formats']:
|
for v_format in info['formats']:
|
||||||
hostName = urllib.parse.urlparse(v_format['url']).netloc
|
hostName = urllib.parse.urlparse(v_format['url']).netloc
|
||||||
v_format['url'] = v_format['url'].replace("https://{}".format(hostName), "") + "&host=" + hostName
|
v_format['url'] = v_format['url'].replace("https://{}".format(hostName), "") + "&host=" + hostName
|
||||||
if v_format['audio_bitrate'] is not None and v_format['vcodec'] is not None:
|
if v_format['audio_bitrate'] is not None and v_format['vcodec'] is None:
|
||||||
v_format['video_valid'] = True
|
|
||||||
elif v_format['audio_bitrate'] is not None and v_format['vcodec'] is None:
|
|
||||||
v_format['audio_valid'] = True
|
v_format['audio_valid'] = True
|
||||||
|
|
||||||
|
# Markup description
|
||||||
info['description'] = Markup(bleach.linkify(info['description'].replace("\n", "<br>")))
|
info['description'] = Markup(bleach.linkify(info['description'].replace("\n", "<br>")))
|
||||||
|
|
||||||
# Get comments
|
# Get comments
|
||||||
videocomments = comments.video_comments(id, sort=0, offset=0, lc='', secret_key='')
|
videocomments = comments.video_comments(id, sort=0, offset=0, lc='', secret_key='')
|
||||||
videocomments = utils.post_process_comments_info(videocomments)
|
videocomments = utils.post_process_comments_info(videocomments)
|
||||||
|
|
||||||
if videocomments is not None:
|
if videocomments is not None:
|
||||||
videocomments.sort(key=lambda x: x['likes'], reverse=True)
|
videocomments.sort(key=lambda x: x['likes'], reverse=True)
|
||||||
|
|
||||||
|
# Calculate rating %
|
||||||
info['rating'] = str((info['like_count'] / (info['like_count'] + info['dislike_count'])) * 100)[0:4]
|
info['rating'] = str((info['like_count'] / (info['like_count'] + info['dislike_count'])) * 100)[0:4]
|
||||||
return render_template("video.html", info=info, title='{}'.format(info['title']), config=config,
|
return render_template("video.html", info=info, title='{}'.format(info['title']), config=config,
|
||||||
videocomments=videocomments)
|
videocomments=videocomments, vsources=vsources)
|
||||||
|
|
||||||
|
|
||||||
def markupString(string):
|
def markupString(string):
|
||||||
|
@ -34,20 +34,18 @@
|
|||||||
</div>
|
</div>
|
||||||
{%else%}
|
{%else%}
|
||||||
<div class="video-js-responsive-container vjs-hd">
|
<div class="video-js-responsive-container vjs-hd">
|
||||||
<video class="video-js vjs-default-skin"
|
<video-js autofocus class="video-js vjs-default-skin"
|
||||||
data-setup='{ "playbackRates": [0.5, 0.75, 1, 1.25,1.5, 1.75, 2] }'
|
data-setup='{ "playbackRates": [0.5, 0.75, 1, 1.25,1.5, 1.75, 2] }'
|
||||||
width="1080"
|
width="1080"
|
||||||
controls
|
controls
|
||||||
buffered
|
buffered
|
||||||
preload="none">
|
preload="none">
|
||||||
{% if config.nginxVideoStream %}
|
{% if config.nginxVideoStream %}
|
||||||
{% for format in info.formats %}
|
{% for source in vsources %}
|
||||||
{% if format.video_valid %}
|
<source src="{{source.src}}" type="{{source.type}}">
|
||||||
<source src="{{format.url}}" type="video/{{format.ext}}">
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</video>
|
</video-js>
|
||||||
</div>
|
</div>
|
||||||
{%endif%}
|
{%endif%}
|
||||||
|
|
||||||
@ -99,7 +97,6 @@
|
|||||||
|
|
||||||
<script src="{{ url_for('static',filename='video.min.js') }}"></script>
|
<script src="{{ url_for('static',filename='video.min.js') }}"></script>
|
||||||
{% if info.live %}
|
{% if info.live %}
|
||||||
<p>Active</p>
|
|
||||||
<script src="{{ url_for('static',filename='videojs-http-streaming.min.js')}}"></script>
|
<script src="{{ url_for('static',filename='videojs-http-streaming.min.js')}}"></script>
|
||||||
<script>
|
<script>
|
||||||
var player = videojs('live');
|
var player = videojs('live');
|
||||||
|
Reference in New Issue
Block a user