Add subscribe button on channels
This commit is contained in:
parent
33bba9762c
commit
2617f87e17
@ -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,
|
||||
|
@ -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')))
|
||||
|
||||
|
@ -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') %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user