diff --git a/lib/WPImport.py b/lib/WPImport.py index d0240a9..c27c22d 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -302,7 +302,7 @@ class WPimport: exit(1) except Exception as err: self._logger.error("{0} : Exception error for update page : {1}".format(self._name, err)) - if page.status_code == 400: + elif page.status_code == 400: self._logger.error("{0} : Connection for update post unauthorized : {1}".format(self._name, page.status_code)) self._logger.debug("{0} : {1}".format(self._name, page.content)) break @@ -817,7 +817,7 @@ class WPimport: listelement[i].append(k["id"]) else: break - if page.status_code == 400: + elif page.status_code == 400: self._logger.error("{0} : {1} not found due status code : {2}".format(self._name, i, page.status_code)) self._logger.debug("{0} : {1}".format(self._name, page.content)) break @@ -867,12 +867,15 @@ class WPimport: bodyhtml = bodyhtml.replace(i["old_href"], o.path) bodyhtml = bodyhtml.replace(i["old_src"], o.path) hour = articledate[0].text - time = dateheader[0].text.split(" ") + time = "" + if len(dateheader) > 0: + time = dateheader[0].text.split(" ") self._logger.debug("{0} : Title post : |{1}|".format(self._name, title)) title = self._removeSpace(title) self._logger.debug("{0} : Rendered Title post : |{1}|".format(self._name, title)) - - data = {"title":title, "content":bodyhtml, "status":"publish", "date": "{0}-{1}-{2}T{3}:00".format(time[2],month[time[1]],time[0], hour), "tags": listelement["tags"], "categories": listelement["categories"]} + data = {"title":title, "content":bodyhtml, "status":"publish", "tags": listelement["tags"], "categories": listelement["categories"]} + if len(dateheader) > 0: + data = {"title":title, "content":bodyhtml, "status":"publish", "date": "{0}-{1}-{2}T{3}:00".format(time[2],month[time[1]],time[0], hour), "tags": listelement["tags"], "categories": listelement["categories"]} self._logger.debug("{0} : Data for post : |{1}| : {2}" .format(self._name, title, data)) data["author"] = self._getAuthor(author)