add private method album

This commit is contained in:
Valentin CZERYBA 2023-08-05 12:03:17 +02:00
parent 02f0c20bd0
commit 28b513e1b2
2 changed files with 15 additions and 4 deletions

View File

@ -55,7 +55,11 @@ class WPimport:
if len(articlebody) > 0: if len(articlebody) > 0:
self._addOrUpdatePost(soup) self._addOrUpdatePost(soup)
else: 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] del webpage_content[first][second][i]
webpage_content = json.dumps(webpage_content) webpage_content = json.dumps(webpage_content)
open("{0}/{1}.json".format(self._tmp, self._name), "wt").write(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: if len(articlebody) > 0:
self._addOrUpdatePost(soup) self._addOrUpdatePost(soup)
else: else:
self._addOrUpdateFeaturedMedia(soup) albumbody = soup.find_all("div", class_="albumbody")
if len(albumbody) > 0:
self._addOrUpdateAlbum(soup)
else:
self._addOrUpdateFeaturedMedia(soup)
# Private method # Private method
def _addOrUpdateAlbum(self, soup):
self._logger.info("{0} : Add/Update Album".format(self._name))
def _fromFileTmp(self): def _fromFileTmp(self):
try: try:
with open("{0}/{1}.json".format(self._tmp, self._name)) as file: with open("{0}/{1}.json".format(self._tmp, self._name)) as file:

View File

@ -86,8 +86,8 @@ class WPMenu:
idMenu = {"id":0, "type":"", "link":""} idMenu = {"id":0, "type":"", "link":""}
soup = BeautifulSoup(content, self._parser) soup = BeautifulSoup(content, self._parser)
articletitle = soup.find("h2", class_="articletitle").get_text() articletitle = soup.find("h2", class_="articletitle").get_text()
if len(articletitle) > 0: if len(articletitle) == 0:
articletitle = soup.find("h2").get_text() articletitle = soup.find("div", class_="albumbody").find("h2").get_text()
exist = False exist = False
for index in range(1,10): for index in range(1,10):
if exist is False: if exist is False: