search title album 50%

This commit is contained in:
Valentin CZERYBA 2023-08-30 22:39:59 +02:00
parent 2e21040196
commit 2279e4b0b6
2 changed files with 17 additions and 3 deletions

View File

@ -170,7 +170,7 @@ if __name__ == '__main__':
import_parser.add_argument("--no-create", help="No create post", dest="create", default="store_false", action="store_true")
import_parser.add_argument("--no-update", help="No update post", dest="update", default="store_false", action="store_true")
import_parser.add_argument("--no-image", help="No image add or update", dest="image", default="store_false", action="store_true")
import_parser.add_argument("--author-album", dest=author, help="Define author for page album", default="")
import_parser.add_argument("--author-album", dest="author", help="Define author for page album", default="")

View File

@ -148,6 +148,7 @@ class WPimport:
response = self._request.get(link)
if response.status_code == 200:
self._logger.info("{0} : get content info from web : {1}".format(self._name, link_o))
page_img = response.content
except ConnectionError as err:
self._logger.error("{0} : Connection error for get album info : {1}".format(self._name, err))
exit(1)
@ -156,6 +157,13 @@ class WPimport:
exit(1)
else:
self._logger.info("{0} : get album info from file : {1}".format(self._name, link_o))
if os.path.exists("{0}/..{1}".format(self._directory, link_o)):
page_img = open("{0}/..{1}".format(self._directory, link_o), "r")
soup = BeautifulSoup(content, self._parser)
paragraph = soup.find("div", class_="albumbody").find("p")
author = paragraph.split("<br>")[1].split(":")[1].replace(" ", "").lower()
return author
def _addOrUpdateAlbum(self, soup):
self._logger.info("{0} : Add/Update Album".format(self._name))
@ -213,6 +221,12 @@ class WPimport:
data = {"title":albumtitle, "content":content_html, "status":"publish"}
if len(self._author) > 0:
author = self._getAuthor(self._author)
else:
link_a = albumbody.find_all("a")
href_a = link_a[0].get("href", "/")
author = self._getInfoAlbum(href_a)
self._logger.info("{0} : author : {1}".format(self._name, author))
self._getAuthor(author)
if author != 0:
data = {"title":albumtitle, "content":content_html, "status":"publish", "author":author}
self._logger.debug("{0} : data for album page : {1}".format(self._name, data))