aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
Diffstat (limited to 'youtube')
-rw-r--r--youtube/channel.py6
-rw-r--r--youtube/subscriptions.py2
-rw-r--r--youtube/templates/channel.html9
3 files changed, 13 insertions, 4 deletions
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 @@
<div class="summary">
<h2 class="title">{{ channel_name }}</h2>
<p class="short-description">{{ short_description }}</p>
+ <form method="POST" action="/youtube.com/subscriptions" class="subscribe-unsubscribe">
+ <input type="submit" value="{{ 'Unsubscribe' if subscribed else 'Subscribe' }}">
+ <input type="hidden" name="channel_id" value="{{ channel_id }}">
+ <input type="hidden" name="channel_name" value="{{ channel_name }}">
+ <input type="hidden" name="action" value="{{ 'unsubscribe' if subscribed else 'subscribe' }}">
+ </form>
</div>
<nav class="channel-tabs">
{% for tab_name in ('Videos', 'Playlists', 'About') %}