delete existing before of reindexing subtitles

This commit is contained in:
simon 2022-02-12 18:22:01 +07:00
parent 13cbada539
commit ce4fa8ee61
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 5 additions and 2 deletions

View File

@ -204,7 +204,9 @@ class Reindex:
video.build_json() video.build_json()
if not video.json_data: if not video.json_data:
video.deactivate() video.deactivate()
return
video.delete_subtitles()
# add back # add back
video.json_data["player"] = player video.json_data["player"] = player
video.json_data["date_downloaded"] = date_downloaded video.json_data["date_downloaded"] = date_downloaded
@ -218,6 +220,7 @@ class Reindex:
thumb_handler.delete_vid_thumb(youtube_id) thumb_handler.delete_vid_thumb(youtube_id)
to_download = (youtube_id, video.json_data["vid_thumb_url"]) to_download = (youtube_id, video.json_data["vid_thumb_url"])
thumb_handler.download_vid([to_download], notify=False) thumb_handler.download_vid([to_download], notify=False)
return
@staticmethod @staticmethod
def reindex_single_channel(channel_id): def reindex_single_channel(channel_id):

View File

@ -422,7 +422,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
os.remove(file_path) os.remove(file_path)
self.del_in_es() self.del_in_es()
self._delete_subtitles() self.delete_subtitles()
def _get_ryd_stats(self): def _get_ryd_stats(self):
"""get optional stats from returnyoutubedislikeapi.com""" """get optional stats from returnyoutubedislikeapi.com"""
@ -452,7 +452,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
self.json_data["subtitles"] = subtitles self.json_data["subtitles"] = subtitles
handler.download_subtitles(relevant_subtitles=subtitles) handler.download_subtitles(relevant_subtitles=subtitles)
def _delete_subtitles(self): def delete_subtitles(self):
"""delete indexed subtitles""" """delete indexed subtitles"""
data = {"query": {"term": {"youtube_id": {"value": self.youtube_id}}}} data = {"query": {"term": {"youtube_id": {"value": self.youtube_id}}}}
_, _ = ElasticWrap("ta_subtitle/_delete_by_query").post(data=data) _, _ = ElasticWrap("ta_subtitle/_delete_by_query").post(data=data)