diff options
author | James Taylor <user234683@users.noreply.github.com> | 2019-01-05 01:23:04 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2019-01-05 01:23:04 -0800 |
commit | 31a60602de1a587a6e84b6bca340fb71241a2187 (patch) | |
tree | 03aede56f900ff82e81e703484247ae680828325 /youtube/youtube.py | |
parent | a57fc774260f2940449880ec9b6aaf40fa2776c3 (diff) | |
download | yt-local-31a60602de1a587a6e84b6bca340fb71241a2187.tar.lz yt-local-31a60602de1a587a6e84b6bca340fb71241a2187.tar.xz yt-local-31a60602de1a587a6e84b6bca340fb71241a2187.zip |
WSGI for /edit_playlist
Diffstat (limited to 'youtube/youtube.py')
-rw-r--r-- | youtube/youtube.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/youtube/youtube.py b/youtube/youtube.py index 639d279..e22ef52 100644 --- a/youtube/youtube.py +++ b/youtube/youtube.py @@ -8,7 +8,7 @@ YOUTUBE_FILES = ( '/comments.css', '/favicon.ico', ) -page_handlers = { +get_handlers = { 'search': search.get_search_page, '': search.get_search_page, 'comments': comments.get_comments_page, @@ -18,6 +18,12 @@ page_handlers = { 'delete_comment': post_comment.get_delete_comment_page, 'login': accounts.get_account_login_page, } +post_handlers = { + 'edit_playlist': local_playlist.edit_playlist, + + +} + def youtube(env, start_response): path, method, query_string = env['PATH_INFO'], env['REQUEST_METHOD'], env['QUERY_STRING'] env['qs_fields'] = urllib.parse.parse_qs(query_string) @@ -28,7 +34,7 @@ def youtube(env, start_response): if method == "GET": try: - handler = page_handlers[path_parts[0]] + handler = get_handlers[path_parts[0]] except KeyError: pass else: @@ -86,15 +92,15 @@ def youtube(env, start_response): env['post_fields'] = post_fields env['fields'].update(post_fields) fields = post_fields - if path == "/edit_playlist": - if fields['action'][0] == 'add': - local_playlist.add_to_playlist(fields['playlist_name'][0], fields['video_info_list']) - start_response('204 No Content', ()) - else: - start_response('400 Bad Request', ()) - return b'400 Bad Request' - elif path.startswith("/playlists"): + try: + handler = post_handlers[path_parts[0]] + except KeyError: + pass + else: + return handler(env, start_response) + + if path.startswith("/playlists"): if fields['action'][0] == 'remove': playlist_name = path[11:] local_playlist.remove_from_playlist(playlist_name, fields['video_info_list']) |