delete playlists of channel when deleting channel, #118

This commit is contained in:
simon 2022-01-05 15:39:41 +07:00
parent 49cd272557
commit 1cbe0bbfc0
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -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