From 2617f87e17b94646eb5a248360a7e0f9b7675d3e Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 10 Aug 2019 18:12:02 -0700 Subject: Add subscribe button on channels --- youtube/channel.py | 6 +++--- youtube/subscriptions.py | 2 +- youtube/templates/channel.html | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'youtube') diff --git a/youtube/channel.py b/youtube/channel.py index 4c7d380..9d0532a 100644 --- a/youtube/channel.py +++ b/youtube/channel.py @@ -1,5 +1,5 @@ import base64 -from youtube import util, yt_data_extract, local_playlist +from youtube import util, yt_data_extract, local_playlist, subscriptions from youtube import yt_app import urllib @@ -312,7 +312,7 @@ def get_channel_page(channel_id, tab='videos'): info['current_sort'] = sort elif tab == 'search': info['search_box_value'] = query - + info['subscribed'] = subscriptions.is_subscribed(info['channel_id']) return flask.render_template('channel.html', parameters_dictionary = request.args, @@ -352,7 +352,7 @@ def get_channel_page_general_url(base_url, tab, request): info['current_sort'] = sort elif tab == 'search': info['search_box_value'] = query - + info['subscribed'] = subscriptions.is_subscribed(info['channel_id']) return flask.render_template('channel.html', parameters_dictionary = request.args, diff --git a/youtube/subscriptions.py b/youtube/subscriptions.py index fa0570c..c347e76 100644 --- a/youtube/subscriptions.py +++ b/youtube/subscriptions.py @@ -519,7 +519,7 @@ def get_subscriptions_page(): def post_subscriptions_page(): action = request.values['action'] if action == 'subscribe': - if len(request.values.getlist('channel_id')) != len(request.values('channel_name')): + if len(request.values.getlist('channel_id')) != len(request.values.getlist('channel_name')): return '400 Bad Request, length of channel_id != length of channel_name', 400 with_open_db(_subscribe, zip(request.values.getlist('channel_id'), request.values.getlist('channel_name'))) diff --git a/youtube/templates/channel.html b/youtube/templates/channel.html index 069e33b..a9f3ac9 100644 --- a/youtube/templates/channel.html +++ b/youtube/templates/channel.html @@ -23,6 +23,9 @@ grid-column:2; margin-left: 5px; } + .summary subscribe-unsubscribe, .summary short-description{ + margin-top: 10px; + } main .channel-tabs{ grid-row:2; grid-column: 1 / span 2; @@ -90,6 +93,12 @@

{{ channel_name }}

{{ short_description }}

+