From ce4fa8ee617e0871fd36cdc6479224154c5db61c Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 12 Feb 2022 18:22:01 +0700 Subject: [PATCH] delete existing before of reindexing subtitles --- tubearchivist/home/src/index/reindex.py | 3 +++ tubearchivist/home/src/index/video.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/src/index/reindex.py b/tubearchivist/home/src/index/reindex.py index 0eea2e3..b694021 100644 --- a/tubearchivist/home/src/index/reindex.py +++ b/tubearchivist/home/src/index/reindex.py @@ -204,7 +204,9 @@ class Reindex: video.build_json() if not video.json_data: video.deactivate() + return + video.delete_subtitles() # add back video.json_data["player"] = player video.json_data["date_downloaded"] = date_downloaded @@ -218,6 +220,7 @@ class Reindex: thumb_handler.delete_vid_thumb(youtube_id) to_download = (youtube_id, video.json_data["vid_thumb_url"]) thumb_handler.download_vid([to_download], notify=False) + return @staticmethod def reindex_single_channel(channel_id): diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index 1d7bf15..7fbbf6f 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -422,7 +422,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): os.remove(file_path) self.del_in_es() - self._delete_subtitles() + self.delete_subtitles() def _get_ryd_stats(self): """get optional stats from returnyoutubedislikeapi.com""" @@ -452,7 +452,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle): self.json_data["subtitles"] = subtitles handler.download_subtitles(relevant_subtitles=subtitles) - def _delete_subtitles(self): + def delete_subtitles(self): """delete indexed subtitles""" data = {"query": {"term": {"youtube_id": {"value": self.youtube_id}}}} _, _ = ElasticWrap("ta_subtitle/_delete_by_query").post(data=data)