From c8cf3316f9df8e5a68b789489665456536b95263 Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 8 Aug 2020 23:37:18 +0200 Subject: [PATCH] show LIVE badge on subscription feed --- app/youtube/__init__.py | 5 +++-- app/youtube/templates/index.html.j2 | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/youtube/__init__.py b/app/youtube/__init__.py index e7f04a6..e57028a 100644 --- a/app/youtube/__init__.py +++ b/app/youtube/__init__.py @@ -32,7 +32,7 @@ def feed(): with sqlite3.connect(cf['global']['database']) as conn: c = conn.cursor() c.execute(""" - SELECT videos.id, channel_id, name, title, length, published, display + SELECT videos.id, channel_id, name, title, length, livestream, published, display FROM videos JOIN channels ON videos.channel_id = channels.id LEFT JOIN flags ON (videos.id = flags.video_id) AND (flags.user = ?) @@ -48,9 +48,10 @@ def feed(): 'author': author, 'title': title, 'length': length, + 'livestream': livestream, 'published': published, 'pinned': display == 'pinned', - } for (video_id, channel_id, author, title, length, published, display) in c.fetchall()] + } for (video_id, channel_id, author, title, length, livestream, published, 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 4d3b2fe..eb28b87 100644 --- a/app/youtube/templates/index.html.j2 +++ b/app/youtube/templates/index.html.j2 @@ -7,7 +7,8 @@ {{ super() }}
{% for row in rows %} - {% call macros.card(row.video_id, row.title, row.published|format_date, row.pinned, row.video_id, badge=row.length|format_time) %} + {% set badge = 'LIVE' if row.livestream else row.length|format_time %} + {% call macros.card(row.video_id, row.title, row.published|format_date, row.pinned, row.video_id, badge=badge) %} {{ macros.infobar_subscriptions(row.video_id, row.channel_id, row.author) }} {% endcall %} {% if row.pinned and not rows[loop.index].pinned %} -- 2.39.3