本文整理汇总了Python中scheduler.Scheduler.vote_song方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.vote_song方法的具体用法?Python Scheduler.vote_song怎么用?Python Scheduler.vote_song使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.vote_song方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import vote_song [as 别名]
else:
session = user.get_session(token)
username = session.json()['user']['name']
if request.form.get('id'):
try:
song_id = int(request.form.get('id'))
except ValueError:
return jsonify({'message': 'Invalid id'}), 400
try:
return jsonify(scheduler.vote_song(username, song_id=song_id))
except Exception, e:
return jsonify({'message': str(e)}), 400
elif request.form.get('url'): # youtube and soundcloud
url = request.form.get('url')
try:
return jsonify(scheduler.vote_song(username, stream_url=url))
except Exception, e:
return jsonify({'message': str(e)}), 400
return jsonify({'message': 'No id or url parameter'}), 400
@app.route('/v1/now_playing', methods=['GET'])
@crossdomain(origin='*')
def now_playing():
return jsonify(player.get_now_playing() or {})
@app.route('/v1/session', methods=['POST'])
@crossdomain(origin='*')
def create_session():
"""Login.
示例2: jsonify
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import vote_song [as 别名]
token = request.form.get('token')
if not AUTHENTICATION_ENABLED:
username = TEST_USERNAME
else:
session = user.get_session(token)
username = session.json()['user']['name']
if request.form.get('id'):
song_id = request.form.get('id')
try:
return jsonify(scheduler.vote_song(username, song_id=song_id))
except Exception, e:
return jsonify({'message': str(e)}), 400
elif request.form.get('url'):
url = request.form.get('url')
try:
return jsonify(scheduler.vote_song(username, video_url=url))
except Exception, e:
return jsonify({'message': str(e)}), 400
return jsonify({'message': 'No id or url parameter'}), 400
@app.route('/v1/now_playing', methods=['GET'])
@crossdomain(origin='*')
def now_playing():
return jsonify(player.get_now_playing() or {})
@app.route('/v1/session', methods=['POST'])
@crossdomain(origin='*')
def create_session():
"""For Crowd SSO support, save the token in a cookie with name 'crowd.token_key'."""
username = request.form.get('username')
password = request.form.get('password')