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