diff --git a/app/routes.py b/app/routes.py index 4eff283..565e647 100644 --- a/app/routes.py +++ b/app/routes.py @@ -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) diff --git a/app/templates/video.html b/app/templates/video.html index 4c295a6..65258d8 100644 --- a/app/templates/video.html +++ b/app/templates/video.html @@ -10,8 +10,9 @@ {% elif video.isUpcoming %}
-
- Empty feed image +
+

SCHEDULED VIDEO

+
{{video.premieres}}
{%else%} diff --git a/youtube_data/videos.py b/youtube_data/videos.py index 3788274..7380cdd 100644 --- a/youtube_data/videos.py +++ b/youtube_data/videos.py @@ -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