diff --git a/tubearchivist/home/src/es/index_mapping.json b/tubearchivist/home/src/es/index_mapping.json index bed6973c..4a325eae 100644 --- a/tubearchivist/home/src/es/index_mapping.json +++ b/tubearchivist/home/src/es/index_mapping.json @@ -462,7 +462,7 @@ } }, { - "index_name": "comments", + "index_name": "comment", "expected_map": { "youtube_id": { "type": "keyword" diff --git a/tubearchivist/home/src/index/comments.py b/tubearchivist/home/src/index/comments.py index 05f9a6ed..a7423ee4 100644 --- a/tubearchivist/home/src/index/comments.py +++ b/tubearchivist/home/src/index/comments.py @@ -16,13 +16,13 @@ class Comments: def __init__(self, youtube_id): self.youtube_id = youtube_id - self.es_path = f"ta_comments/_doc/{youtube_id}" + self.es_path = f"ta_comment/_doc/{youtube_id}" self.max_comments = "all,100,all,30" self.json_data = False def build_json(self): """build json document for es""" - comments_raw = self.get_comments() + comments_raw = self.get_yt_comments() comments_format = self.format_comments(comments_raw) self.json_data = { @@ -53,7 +53,7 @@ class Comments: return yt_obs - def get_comments(self): + def get_yt_comments(self): """get comments from youtube""" print(f"comments: get comments with format {self.max_comments}") yt_obs = self.build_yt_obs() @@ -99,3 +99,12 @@ class Comments: def delete_comments(self): """delete comments from es""" _, _ = ElasticWrap(self.es_path).delete() + + def get_es_comments(self): + """get comments from ES""" + response, statuscode = ElasticWrap(self.es_path).get() + if statuscode == 404: + print(f"comments: not found {self.youtube_id}") + return False + + return response