WSGI for /delete_comment (POST request)
This commit is contained in:
parent
60df0aec6d
commit
28270a9ce8
@ -109,11 +109,18 @@ def get_session_token(video_id, cookiejar):
|
|||||||
else:
|
else:
|
||||||
raise Exception("Couldn't find xsrf_token")
|
raise Exception("Couldn't find xsrf_token")
|
||||||
|
|
||||||
def delete_comment(parameters, fields):
|
def delete_comment(env, start_response):
|
||||||
|
fields = env['fields']
|
||||||
video_id = fields['video_id'][0]
|
video_id = fields['video_id'][0]
|
||||||
cookiejar = accounts.account_cookiejar(fields['channel_id'][0])
|
cookiejar = accounts.account_cookiejar(fields['channel_id'][0])
|
||||||
token = get_session_token(video_id, cookiejar)
|
token = get_session_token(video_id, cookiejar)
|
||||||
return _delete_comment(video_id, fields['comment_id'][0], fields['author_id'][0], token, cookiejar)
|
|
||||||
|
code = _delete_comment(video_id, fields['comment_id'][0], fields['author_id'][0], token, cookiejar)
|
||||||
|
|
||||||
|
if code == "SUCCESS":
|
||||||
|
start_response('303 See Other', [('Location', common.URL_ORIGIN + '/comment_delete_success'),] )
|
||||||
|
else:
|
||||||
|
start_response('303 See Other', [('Location', common.URL_ORIGIN + '/comment_delete_fail'),] )
|
||||||
|
|
||||||
def post_comment(parameters, fields):
|
def post_comment(parameters, fields):
|
||||||
channel_id = fields['channel_id'][0]
|
channel_id = fields['channel_id'][0]
|
||||||
|
@ -21,6 +21,7 @@ get_handlers = {
|
|||||||
post_handlers = {
|
post_handlers = {
|
||||||
'edit_playlist': local_playlist.edit_playlist,
|
'edit_playlist': local_playlist.edit_playlist,
|
||||||
'login': accounts.add_account,
|
'login': accounts.add_account,
|
||||||
|
'delete_comment': post_comment.delete_comment,
|
||||||
}
|
}
|
||||||
|
|
||||||
def youtube(env, start_response):
|
def youtube(env, start_response):
|
||||||
@ -123,14 +124,6 @@ def youtube(env, start_response):
|
|||||||
start_response('303 See Other', (('Location', common.URL_ORIGIN + '/comments?ctoken=' + comments.make_comment_ctoken(video_id, sort=1)),) )
|
start_response('303 See Other', (('Location', common.URL_ORIGIN + '/comments?ctoken=' + comments.make_comment_ctoken(video_id, sort=1)),) )
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
elif path == "/delete_comment":
|
|
||||||
parameters = urllib.parse.parse_qs(query_string)
|
|
||||||
code = post_comment.delete_comment(parameters, fields)
|
|
||||||
if code == "SUCCESS":
|
|
||||||
start_response('303 See Other', (('Location', common.URL_ORIGIN + '/comment_delete_success'),) )
|
|
||||||
else:
|
|
||||||
start_response('303 See Other', (('Location', common.URL_ORIGIN + '/comment_delete_fail'),) )
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
start_response('404 Not Found', ())
|
start_response('404 Not Found', ())
|
||||||
return b'404 Not Found'
|
return b'404 Not Found'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user