skip empty comment, #429

This commit is contained in:
simon 2023-02-13 12:42:55 +07:00
parent 77c26134d1
commit 6641db3e7e
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 8 additions and 0 deletions

View File

@ -109,12 +109,20 @@ class Comments:
if comments_raw:
for comment in comments_raw:
cleaned_comment = self.clean_comment(comment)
if not cleaned_comment:
continue
comments.append(cleaned_comment)
self.comments_format = comments
def clean_comment(self, comment):
"""parse metadata from comment for indexing"""
if not comment.get("text"):
# comment text can be empty
print(f"{self.youtube_id}: Failed to extract text, {comment}")
return False
time_text_datetime = datetime.utcfromtimestamp(comment["timestamp"])
if time_text_datetime.hour == 0 and time_text_datetime.minute == 0: