From 66f396ce32bf2b5c869e63ceb649bbcf510d7034 Mon Sep 17 00:00:00 2001 From: Mageas Date: Thu, 9 Sep 2021 09:56:46 +0200 Subject: Add a button to remove playlist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jesús --- youtube/local_playlist.py | 6 ++++++ youtube/templates/local_playlist.html | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/youtube/local_playlist.py b/youtube/local_playlist.py index 40ff035..aa3ac27 100644 --- a/youtube/local_playlist.py +++ b/youtube/local_playlist.py @@ -153,6 +153,12 @@ def path_edit_playlist(playlist_name): number_of_videos_remaining = remove_from_playlist(playlist_name, videos_to_remove) redirect_page_number = min(int(request.values.get('page', 1)), math.ceil(number_of_videos_remaining/50)) return flask.redirect(util.URL_ORIGIN + request.path + '?page=' + str(redirect_page_number)) + elif request.values['action'] == 'remove_playlist': + try: + os.remove(os.path.join(playlists_directory, playlist_name + ".txt")) + except OSError: + pass + return flask.redirect(util.URL_ORIGIN + '/playlists') elif request.values['action'] == 'export': videos = read_playlist(playlist_name) fmt = request.values['export_format'] diff --git a/youtube/templates/local_playlist.html b/youtube/templates/local_playlist.html index 64abcf4..d08aa48 100644 --- a/youtube/templates/local_playlist.html +++ b/youtube/templates/local_playlist.html @@ -22,7 +22,9 @@ +
@@ -31,6 +33,12 @@ {{ common_elements.item(video_info) }} {% endfor %} +