From 4cf301b2169d9757d501018ebe9395933fd32137 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 16 Apr 2023 21:25:32 +0200 Subject: [PATCH] parent comment 90% --- lib/WPImport.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/WPImport.py b/lib/WPImport.py index 4760aa5..47db168 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -215,6 +215,18 @@ class WPimport: if page.status_code == 200: self._logger.info("Commentaire mise à jour pour {0}".format(title)) else: + if i["parent_id"] != -1: + parent_id = int(i["parent_id"]) + try: + page = self._request.get("http://{0}/wp-json/wp/v2/comments".format(self._wordpress), auth=self._basic, params=params) + except Exception as err: + self._logger.error("Connection error : {0}".format(err)) + exit(1) + if page.status_code == 200: + result = page.json() + for j in result: + if comment[parent_id]["author"] == j["author_name"] and comment[parent_id]["date"] == j["date"]: + data["parent"]=j["id"] try: page = self._request.post("http://{0}/wp-json/wp/v2/comments".format(self._wordpress), auth=self._basic, data=data) except Exception as err: