cleanup subtitles after deleting channels

This commit is contained in:
Simon 2023-12-25 11:40:09 +07:00
parent 5b26433599
commit 86fe31d258
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 10 additions and 0 deletions

View File

@ -199,6 +199,15 @@ class YoutubeChannel(YouTubeItem):
}
_, _ = ElasticWrap("ta_comment/_delete_by_query").post(data)
def delete_es_subtitles(self):
"""delete all subtitles from this channel"""
data = {
"query": {
"term": {"subtitle_channel_id": {"value": self.youtube_id}}
}
}
_, _ = ElasticWrap("ta_subtitle/_delete_by_query").post(data)
def delete_playlists(self):
"""delete all indexed playlist from es"""
all_playlists = self.get_indexed_playlists()
@ -229,6 +238,7 @@ class YoutubeChannel(YouTubeItem):
print(f"{self.youtube_id}: delete indexed videos")
self.delete_es_videos()
self.delete_es_comments()
self.delete_es_subtitles()
self.del_in_es()
def index_channel_playlists(self):