Follow/Unfollow from channel page
This commit is contained in:
parent
df7a62649b
commit
66fa65dfca
@ -264,13 +264,13 @@ def ytfollow(channelId):
|
||||
db.session.commit()
|
||||
except:
|
||||
flash("Something went wrong. Try again!")
|
||||
return redirect(url_for('invidious'))
|
||||
return redirect(request.referrer)
|
||||
flash('You are following {}!'.format(channelId))
|
||||
else:
|
||||
flash("Something went wrong... try again")
|
||||
return redirect(url_for('ytsearch'))
|
||||
return redirect(request.referrer)
|
||||
else:
|
||||
return redirect(url_for('ytsearch'))
|
||||
return redirect(request.referrer)
|
||||
|
||||
@app.route('/ytunfollow/<channelId>', methods=['POST'])
|
||||
@login_required
|
||||
@ -283,17 +283,19 @@ def ytunfollow(channelId):
|
||||
flash("User unfollowed!")
|
||||
except:
|
||||
flash("There was an error unfollowing the user. Try again.")
|
||||
return redirect(url_for('ytsearch'))
|
||||
return redirect(request.referrer)
|
||||
|
||||
@app.route('/channel/<id>', methods=['GET'])
|
||||
@login_required
|
||||
def channel(id):
|
||||
form = ChannelForm()
|
||||
button_form = EmptyForm()
|
||||
data = requests.get('https://www.youtube.com/feeds/videos.xml?channel_id={id}'.format(id=id))
|
||||
data = feedparser.parse(data.content)
|
||||
|
||||
channelData = YoutubeSearch.channelInfo(id)
|
||||
|
||||
return render_template('channel.html', channel=channelData[0], videos=channelData[1])
|
||||
return render_template('channel.html', form=form, btform=button_form, channel=channelData[0], videos=channelData[1])
|
||||
|
||||
@app.route('/watch', methods=['GET'])
|
||||
@login_required
|
||||
|
@ -14,7 +14,22 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra content">
|
||||
<div class="center aligned extra content">
|
||||
{% if not current_user.is_following_yt(channel.id) %}
|
||||
<p>
|
||||
<form action="{{ url_for('ytfollow', channelId=channel.id) }}" method="post">
|
||||
{{ btform.hidden_tag() }}
|
||||
{{ btform.submit(value='Follow') }}
|
||||
</form>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
<form action="{{ url_for('ytunfollow', channelId=channel.id) }}" method="post">
|
||||
{{ btform.hidden_tag() }}
|
||||
{{ btform.submit(value='Unfollow') }}
|
||||
</form>
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user