mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
rename ta_comment index, implement get comments from es
This commit is contained in:
parent
5b7e3e877b
commit
f6b6185fb2
@ -462,7 +462,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"index_name": "comments",
|
||||
"index_name": "comment",
|
||||
"expected_map": {
|
||||
"youtube_id": {
|
||||
"type": "keyword"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user