From 1cbe0bbfc01ddf4ac96845d6acd1a6cc2103c04f Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 5 Jan 2022 15:39:41 +0700 Subject: [PATCH] delete playlists of channel when deleting channel, #118 --- tubearchivist/home/src/index.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/src/index.py b/tubearchivist/home/src/index.py index b53edd2..63a1349 100644 --- a/tubearchivist/home/src/index.py +++ b/tubearchivist/home/src/index.py @@ -224,6 +224,13 @@ class YoutubeChannel: if not response.ok: print(response.text) + def delete_playlists(self): + """delete all indexed playlist from es""" + all_playlists = self.get_indexed_playlists() + for playlist in all_playlists: + playlist_id = playlist["playlist_id"] + YoutubePlaylist(playlist_id).delete_metadata() + def delete_channel(self): """delete channel and all videos""" print(f"deleting {self.channel_id} and all matching media files") @@ -239,7 +246,8 @@ class YoutubeChannel: print(f"no videos found for {folder_path}") ThumbManager().delete_chan_thumb(self.channel_id) - + print("delete indexed playlists") + self.delete_playlists() print("delete indexed videos") self.delete_es_videos() url = self.ES_URL + "/ta_channel/_doc/" + self.channel_id