diff --git a/tubearchivist/home/templates/home/playlist_id.html b/tubearchivist/home/templates/home/playlist_id.html index f940706..59d2629 100644 --- a/tubearchivist/home/templates/home/playlist_id.html +++ b/tubearchivist/home/templates/home/playlist_id.html @@ -31,12 +31,19 @@ false {% endif %}

+ +
+ Delete {{ playlist_info.playlist_name }}? + +
+ +
{% if max_hits %} -

Total Videos archived: {{ playlist_info.playlist_entries|length }}/{{ max_hits }}

+

Total Videos archived: {{ max_hits }}/{{ playlist_info.playlist_entries|length }}

Watched:

{% endif %}
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index d3ae262..38b118b 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -1009,6 +1009,7 @@ class PostData: "channel-search": self.channel_search, "delete-video": self.delete_video, "delete-channel": self.delete_channel, + "delete-playlist": self.delete_playlist, "find-playlists": self.find_playlists, } @@ -1202,6 +1203,19 @@ class PostData: YoutubeChannel(channel_id).delete_channel() return {"success": True} + def delete_playlist(self): + """delete playlist, only metadata or incl all videos""" + playlist_dict = self.exec_val + playlist_id = playlist_dict["playlist-id"] + playlist_action = playlist_dict["playlist-action"] + print(f"delete {playlist_action} from playlist {playlist_id}") + if playlist_action == "metadata": + YoutubePlaylist(playlist_id).delete_metadata() + elif playlist_action == "all": + YoutubePlaylist(playlist_id).delete_videos_playlist() + + return {"success": True} + def find_playlists(self): """add all playlists of a channel""" channel_id = self.exec_val diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index 06e6311..5343796 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -209,6 +209,10 @@ button:hover { display: none; } +.delete-confirm button { + margin: 3px 0; +} + .danger-button { background-color: var(--highlight-error); } diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index f6c9680..f3e7d39 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -239,6 +239,23 @@ function deleteChannel(button) { }, 1000); } +function deletePlaylist(button) { + var playlist_id = button.getAttribute("data-id"); + var playlist_action = button.getAttribute("data-action"); + var payload = JSON.stringify({ + "delete-playlist": { + "playlist-id": playlist_id, + "playlist-action": playlist_action + } + }); + console.log(payload); + sendPost(payload); + setTimeout(function(){ + window.location.replace("/playlist/"); + return false; + }, 1000); +} + function cancelDelete() { document.getElementById("delete-button").style.display = 'none'; document.getElementById("delete-item").style.display = 'block';