aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--youtube/subscriptions.py24
-rw-r--r--youtube/templates/subscriptions.html2
2 files changed, 18 insertions, 8 deletions
diff --git a/youtube/subscriptions.py b/youtube/subscriptions.py
index ba1f334..3cb02ff 100644
--- a/youtube/subscriptions.py
+++ b/youtube/subscriptions.py
@@ -120,12 +120,21 @@ def _unsubscribe(cursor, channel_ids):
gevent.spawn(delete_thumbnails, to_delete)
cursor.executemany("DELETE FROM subscribed_channels WHERE yt_channel_id=?", ((channel_id, ) for channel_id in channel_ids))
-def _get_videos(cursor, number, offset):
- db_videos = cursor.execute('''SELECT video_id, title, duration, channel_name
- FROM videos
- INNER JOIN subscribed_channels on videos.sql_channel_id = subscribed_channels.id
- ORDER BY time_published DESC
- LIMIT ? OFFSET ?''', (number, offset))
+def _get_videos(cursor, number, offset, tag = None):
+ if tag is not None:
+ db_videos = cursor.execute('''SELECT video_id, title, duration, channel_name
+ FROM videos
+ INNER JOIN subscribed_channels on videos.sql_channel_id = subscribed_channels.id
+ INNER JOIN tag_associations on videos.sql_channel_id = tag_associations.sql_channel_id
+ WHERE tag = ?
+ ORDER BY time_published DESC
+ LIMIT ? OFFSET ?''', (tag, number, offset))
+ else:
+ db_videos = cursor.execute('''SELECT video_id, title, duration, channel_name
+ FROM videos
+ INNER JOIN subscribed_channels on videos.sql_channel_id = subscribed_channels.id
+ ORDER BY time_published DESC
+ LIMIT ? OFFSET ?''', (number, offset))
for db_video in db_videos:
yield {
@@ -481,8 +490,9 @@ def post_subscription_manager_page():
def get_subscriptions_page():
with open_database() as connection:
with connection as cursor:
+ tag = request.args.get('tag', None)
videos = []
- for video in _get_videos(cursor, 60, 0):
+ for video in _get_videos(cursor, 60, 0, tag):
video['thumbnail'] = util.URL_ORIGIN + '/data/subscription_thumbnails/' + video['id'] + '.jpg'
video['type'] = 'video'
video['item_size'] = 'small'
diff --git a/youtube/templates/subscriptions.html b/youtube/templates/subscriptions.html
index a3227b1..442bd88 100644
--- a/youtube/templates/subscriptions.html
+++ b/youtube/templates/subscriptions.html
@@ -64,7 +64,7 @@
<ol class="sidebar-list tags">
{% for tag in tags %}
<li class="sidebar-list-item">
- <span class="sidebar-item-name">{{ tag }}</span>
+ <a href="?tag={{ tag|urlencode }}" class="sidebar-item-name">{{ tag }}</a>
<form method="POST" class="sidebar-item-refresh">
<input type="submit" value="Check">
<input type="hidden" name="action" value="refresh">