diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-07-20 01:41:12 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-07-20 01:41:12 -0700 |
commit | d170a75a93e7d722345e328235d62e41cbcd6ae0 (patch) | |
tree | 242ad2e26677a9bcd6640f9f9b2dd68b8d2ab9ab /youtube/youtube.py | |
parent | f12157cd0203d61bd5ee4f6142562da17f3109a7 (diff) | |
download | yt-local-d170a75a93e7d722345e328235d62e41cbcd6ae0.tar.lz yt-local-d170a75a93e7d722345e328235d62e41cbcd6ae0.tar.xz yt-local-d170a75a93e7d722345e328235d62e41cbcd6ae0.zip |
ability to remove videos from playlist
Diffstat (limited to 'youtube/youtube.py')
-rw-r--r-- | youtube/youtube.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/youtube/youtube.py b/youtube/youtube.py index aa23d06..a9bd3c4 100644 --- a/youtube/youtube.py +++ b/youtube/youtube.py @@ -57,8 +57,20 @@ def youtube(env, start_response): fields = urllib.parse.parse_qs(env['wsgi.input'].read().decode()) if fields['action'][0] == 'add': local_playlist.add_to_playlist(fields['playlist_name'][0], fields['video_info_list']) - - start_response('204 No Content', ()) + start_response('204 No Content', ()) + elif fields['action'][0] == 'remove': + try: + playlist_name = fields['playlist_page'][0] + except KeyError: + playlist_name = fields['playlist_name'][0] + local_playlist.remove_from_playlist(playlist_name, fields['video_info_list']) + start_response('200 OK', ()) + return local_playlist.get_playlist_page(playlist_name).encode() + else: + start_response('400 Bad Request', ()) + return b'400 Bad Request' + + else: start_response('404 Not Found', ()) return b'404 Not Found' |