Fix scheduled videos
This commit is contained in:
parent
d1ec8e20b6
commit
5d510101ab
@ -378,21 +378,18 @@ def watch():
|
||||
id = request.args.get('v', None)
|
||||
info = ytvids.get_video_info(id)
|
||||
hostName = urllib.parse.urlparse(info['video']['url']).netloc
|
||||
audioHostName = urllib.parse.urlparse(info['video']['audio']['url']).netloc
|
||||
|
||||
# Use nginx
|
||||
try:
|
||||
url = info['video']['url'].replace("https://{}".format(hostName), "")+"&host="+hostName
|
||||
except:
|
||||
url = "#"
|
||||
|
||||
|
||||
try:
|
||||
audioHostName = urllib.parse.urlparse(info['video']['audio']['url'])
|
||||
audioUrl = info['video']['audio']['url'].replace("https://{}".format(audioHostName), "")+"&host="+audioHostName
|
||||
print(audioUrl)
|
||||
except:
|
||||
audioUrl = False
|
||||
|
||||
print(info['video']['thumbnail'])
|
||||
video={
|
||||
'title':info['video']['title'],
|
||||
'description':Markup(markupString(info['video']['description'])),
|
||||
@ -408,7 +405,8 @@ def watch():
|
||||
'isLive': info['video']['isLive'],
|
||||
'isUpcoming': info['video']['isUpcoming'],
|
||||
'thumbnail': info['video']['thumbnail'],
|
||||
'nginxAudioUrl': audioUrl
|
||||
'nginxAudioUrl': audioUrl,
|
||||
'premieres': info['video']['premieres']
|
||||
}
|
||||
return render_template("video.html", video=video, title='{}'.format(video['title']), config=config)
|
||||
|
||||
|
@ -10,8 +10,9 @@
|
||||
</div>
|
||||
{% elif video.isUpcoming %}
|
||||
<div class="ui center aligned text container">
|
||||
<div class="ui row">
|
||||
<img alt="Empty feed image" class="ui image" src="{{ url_for('static',filename='img/scheduled.png') }}">
|
||||
<div class="ui segment">
|
||||
<h4 class="ui header">SCHEDULED VIDEO</h4>
|
||||
<h5 class="ui header">{{video.premieres}}</h5>
|
||||
</div>
|
||||
</div>
|
||||
{%else%}
|
||||
|
@ -131,6 +131,11 @@ def get_video_primary_info(datad, datai):
|
||||
if not isUpcoming:
|
||||
views = details['viewCount']
|
||||
|
||||
if isUpcoming:
|
||||
premieres = item['dateText']['simpleText']
|
||||
else:
|
||||
premieres = False
|
||||
|
||||
ydl = YoutubeDL()
|
||||
try:
|
||||
data = ydl.extract_info(details['videoId'], False)
|
||||
@ -161,6 +166,10 @@ def get_video_primary_info(datad, datai):
|
||||
except:
|
||||
url = "#"
|
||||
try:
|
||||
if isUpcoming:
|
||||
audioURL = False
|
||||
else:
|
||||
audioURL = audio_urls[-1]
|
||||
primaryInfo = {
|
||||
"id": details['videoId'],
|
||||
"title": details['title'],
|
||||
@ -176,10 +185,15 @@ def get_video_primary_info(datad, datai):
|
||||
"allowRatings": details['allowRatings'],
|
||||
"url":url,
|
||||
"thumbnail": details['thumbnail']['thumbnails'][0]['url'],
|
||||
"audio": audio_urls[-1]
|
||||
"audio": audioURL,
|
||||
"premieres": premieres
|
||||
}
|
||||
except:
|
||||
# If error take only most common items
|
||||
if isUpcoming:
|
||||
audioURL = False
|
||||
else:
|
||||
audioURL = audio_urls[-1]
|
||||
primaryInfo = {
|
||||
"id": details['videoId'],
|
||||
"title": details['title'],
|
||||
@ -195,7 +209,8 @@ def get_video_primary_info(datad, datai):
|
||||
"allowRatings":True,
|
||||
"url":url,
|
||||
"thumbnail": details['thumbnail']['thumbnails'][0]['url'],
|
||||
"audio": audio_urls[-1]
|
||||
"audio": audioURL,
|
||||
"premieres": premieres
|
||||
}
|
||||
return primaryInfo
|
||||
|
||||
|
Reference in New Issue
Block a user