diff --git a/lib/WPImport.py b/lib/WPImport.py index 9f0767a..60d6980 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -55,7 +55,11 @@ class WPimport: if len(articlebody) > 0: self._addOrUpdatePost(soup) else: - self._addOrUpdateFeaturedMedia(soup) + albumbody = soup.find_all("div", class_="albumbody") + if len(albumbody) > 0: + self._addOrUpdateAlbum(soup) + else: + self._addOrUpdateFeaturedMedia(soup) del webpage_content[first][second][i] webpage_content = json.dumps(webpage_content) open("{0}/{1}.json".format(self._tmp, self._name), "wt").write(webpage_content) @@ -100,12 +104,19 @@ class WPimport: if len(articlebody) > 0: self._addOrUpdatePost(soup) else: - self._addOrUpdateFeaturedMedia(soup) + albumbody = soup.find_all("div", class_="albumbody") + if len(albumbody) > 0: + self._addOrUpdateAlbum(soup) + else: + self._addOrUpdateFeaturedMedia(soup) # Private method + def _addOrUpdateAlbum(self, soup): + self._logger.info("{0} : Add/Update Album".format(self._name)) + def _fromFileTmp(self): try: with open("{0}/{1}.json".format(self._tmp, self._name)) as file: diff --git a/lib/WPMenu.py b/lib/WPMenu.py index bcb34a2..1bddf6e 100644 --- a/lib/WPMenu.py +++ b/lib/WPMenu.py @@ -86,8 +86,8 @@ class WPMenu: idMenu = {"id":0, "type":"", "link":""} soup = BeautifulSoup(content, self._parser) articletitle = soup.find("h2", class_="articletitle").get_text() - if len(articletitle) > 0: - articletitle = soup.find("h2").get_text() + if len(articletitle) == 0: + articletitle = soup.find("div", class_="albumbody").find("h2").get_text() exist = False for index in range(1,10): if exist is False: