diff --git a/tubearchivist/home/src/index/comments.py b/tubearchivist/home/src/index/comments.py index b98a6915..3ad7c9e2 100644 --- a/tubearchivist/home/src/index/comments.py +++ b/tubearchivist/home/src/index/comments.py @@ -26,7 +26,7 @@ class Comments: def build_json(self): """build json document for es""" print(f"{self.youtube_id}: get comments") - self._check_config() + self.check_config() if not self.is_activated: return @@ -40,7 +40,7 @@ class Comments: "comment_comments": self.comments_format, } - def _check_config(self): + def check_config(self): """read config if not attached""" if not self.config: self.config = AppConfig().config @@ -127,6 +127,7 @@ class Comments: def delete_comments(self): """delete comments from es""" + print(f"{self.youtube_id}: delete comments") _, _ = ElasticWrap(self.es_path).delete(refresh=True) def get_es_comments(self): diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index 9264080f..7780c631 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -11,6 +11,7 @@ import requests from django.conf import settings from home.src.es.connect import ElasticWrap from home.src.index import channel as ta_channel +from home.src.index import comments as ta_comments from home.src.index import playlist as ta_playlist from home.src.index.generic import YouTubeItem from home.src.index.subtitle import YoutubeSubtitle @@ -302,6 +303,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): self.del_in_playlists() self.del_in_es() self.delete_subtitles() + self.delete_comments() def del_in_playlists(self): """remove downloaded in playlist""" @@ -326,6 +328,13 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): print(f"{self.youtube_id}: delete subtitles") YoutubeSubtitle(self).delete(subtitles=subtitles) + def delete_comments(self): + """delete comments from es""" + comments = ta_comments.Comments(self.youtube_id, config=self.config) + comments.check_config() + if comments.is_activated: + comments.delete_comments() + def _get_ryd_stats(self): """get optional stats from returnyoutubedislikeapi.com""" # pylint: disable=broad-except