From 2f824c438b24cb147081fd911930856a63c3b6ab Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 29 Apr 2023 18:30:06 +0000 Subject: [PATCH] mark upcoming livestreams as 'SOON' livestreams currently live and finished livestreams will show 'LIVE'. the latter is a limitation of our collected data (at the time of crawling, livestreams have no duration which we could show). --- app/youtube/__init__.py | 9 ++++----- app/youtube/templates/index.html.j2 | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/youtube/__init__.py b/app/youtube/__init__.py index 81f01e3..08c81ba 100644 --- a/app/youtube/__init__.py +++ b/app/youtube/__init__.py @@ -47,7 +47,7 @@ def feed(): } c.execute(""" - SELECT videos.id, channel_id, name, title, length, livestream, premiere, shorts, published, playlist_videos.playlist_id, display + SELECT videos.id, channel_id, name, title, length, livestream, premiere, shorts, published > datetime('now') as upcoming, published, playlist_videos.playlist_id, display FROM videos JOIN channels ON videos.channel_id = channels.id LEFT JOIN playlist_videos ON (videos.id = playlist_videos.video_id) @@ -67,14 +67,13 @@ def feed(): 'title': title, 'length': length, 'livestream': livestream, - 'premiere': premiere and (# only if it hasn't yet premiered: - datetime.strptime(published+'+0000', "%Y-%m-%d %H:%M:%S%z")>datetime.now(tz=timezone.utc) - ), + 'premiere': premiere, 'shorts': shorts, + 'upcoming': upcoming, 'published': published, 'playlist': playlist, 'pinned': display == 'pinned', - } for (video_id, channel_id, author, title, length, livestream, premiere, shorts, published, playlist, display) in c.fetchall()] + } for (video_id, channel_id, author, title, length, livestream, premiere, shorts, upcoming, published, playlist, display) in c.fetchall()] return render_template('index.html.j2', rows=rows, page=page) @frontend.route('/watch') diff --git a/app/youtube/templates/index.html.j2 b/app/youtube/templates/index.html.j2 index 9347427..3d86f09 100644 --- a/app/youtube/templates/index.html.j2 +++ b/app/youtube/templates/index.html.j2 @@ -7,7 +7,7 @@ {{ super() }}
{% for row in rows %} - {% set badge = 'shorts' if row.shorts else 'LIVE' if row.livestream else 'SOON' if row.premiere else row.length|format_time %} + {% set badge = 'shorts' if row.shorts else 'SOON' if row.upcoming else 'LIVE' if row.livestream else row.length|format_time %} {% call macros.card(row.video_id, row.title, row.published|format_date, row.pinned, badge=badge) %} {{ macros.infobar_subscriptions(row.video_id, row.channel_id, row.author) }} {% endcall %} -- 2.39.3