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()
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):

View File

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