continue indexing if comment indexing failes, #383

This commit is contained in:
simon 2022-12-19 14:59:07 +07:00
parent f45a3095cb
commit e804dd1aec
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 16 additions and 8 deletions

View File

@ -150,7 +150,8 @@ class DownloadPostProcess:
for idx, video_id in enumerate(self.download.videos):
comment = Comments(video_id, config=self.download.config)
comment.build_json(notify=(idx, total_videos))
comment.upload_comments()
if comment.json_data:
comment.upload_comments()
key = "message:download"
message = {

View File

@ -33,10 +33,10 @@ class Comments:
self._send_notification(notify)
comments_raw, channel_id = self.get_yt_comments()
if comments_raw:
self.format_comments(comments_raw)
else:
self.comments_format = []
if not comments_raw and not channel_id:
return
self.format_comments(comments_raw)
self.json_data = {
"youtube_id": self.youtube_id,
@ -96,6 +96,9 @@ class Comments:
"""get comments from youtube"""
yt_obs = self.build_yt_obs()
info_json = YtWrap(yt_obs).extract(self.youtube_id)
if not info_json:
return False, False
comments_raw = info_json.get("comments")
channel_id = info_json.get("channel_id")
return comments_raw, channel_id
@ -104,9 +107,10 @@ class Comments:
"""process comments to match format"""
comments = []
for comment in comments_raw:
cleaned_comment = self.clean_comment(comment)
comments.append(cleaned_comment)
if comments_raw:
for comment in comments_raw:
cleaned_comment = self.clean_comment(comment)
comments.append(cleaned_comment)
self.comments_format = comments
@ -169,6 +173,9 @@ class Comments:
return
self.build_json()
if not self.json_data:
return
es_comments = self.get_es_comments()
if not self.comments_format: