Compare commits
10 Commits
41e192f903
...
4.0.3
Author | SHA1 | Date | |
---|---|---|---|
9ab484da8d | |||
c275f10fb0 | |||
fa1854052b | |||
0e5afe60a7 | |||
d2cfb949f8 | |||
bce1643135 | |||
0c94783852 | |||
6f78a48e57 | |||
dbab60c7dc | |||
dce2c2dfa5 |
@@ -141,7 +141,7 @@ class WPimport:
|
|||||||
|
|
||||||
def _getInfoAlbum(self, link):
|
def _getInfoAlbum(self, link):
|
||||||
if self._ssl_canalblog:
|
if self._ssl_canalblog:
|
||||||
link = link.replace("http", "https")
|
link = link.replace("http", "https").replace("httpss", "https")
|
||||||
self._logger.info("{0} : Info album : {1}".format(self._name, link))
|
self._logger.info("{0} : Info album : {1}".format(self._name, link))
|
||||||
link_o = urlparse(link)
|
link_o = urlparse(link)
|
||||||
if len(link_o.netloc) > 0:
|
if len(link_o.netloc) > 0:
|
||||||
@@ -162,13 +162,16 @@ class WPimport:
|
|||||||
if os.path.exists("{0}/..{1}".format(self._directory, link_o)):
|
if os.path.exists("{0}/..{1}".format(self._directory, link_o)):
|
||||||
page_img = open("{0}/..{1}".format(self._directory, link_o), "r")
|
page_img = open("{0}/..{1}".format(self._directory, link_o), "r")
|
||||||
soup = BeautifulSoup(page_img, self._parser)
|
soup = BeautifulSoup(page_img, self._parser)
|
||||||
paragraph = soup.find("div", class_="albumbody").find("p")
|
paragraphs = soup.find("div", class_="albumbody").find_all("p")
|
||||||
|
for paragraph in paragraphs:
|
||||||
self._logger.info("{0} get paragraph : {1}".format(self._name, paragraph))
|
self._logger.info("{0} get paragraph : {1}".format(self._name, paragraph))
|
||||||
split_paragraph = str(paragraph).split("<br>")
|
split_paragraph = str(paragraph).split("<br>")
|
||||||
self._logger.info("{0} length paragraph splitted : {1}".format(self._name, len(split_paragraph)))
|
self._logger.info("{0} length paragraph splitted : {1}".format(self._name, len(split_paragraph)))
|
||||||
if len(split_paragraph) == 1:
|
if len(split_paragraph) == 1:
|
||||||
split_paragraph = str(paragraph).split("<br/>")
|
split_paragraph = str(paragraph).split("<br/>")
|
||||||
self._logger.info("{0} get paragraph splitted : {1}".format(self._name, split_paragraph))
|
self._logger.info("{0} get paragraph splitted : {1}".format(self._name, split_paragraph))
|
||||||
|
if len(split_paragraph) > 1:
|
||||||
|
if len(split_paragraph[1].split(":")) > 1:
|
||||||
author = split_paragraph[1].split(":")[1].replace(" ", "").lower()
|
author = split_paragraph[1].split(":")[1].replace(" ", "").lower()
|
||||||
return author
|
return author
|
||||||
|
|
||||||
@@ -458,6 +461,21 @@ class WPimport:
|
|||||||
self._logger.error("{0} : Exception error for post media featured : {1}".format(self._name, err))
|
self._logger.error("{0} : Exception error for post media featured : {1}".format(self._name, err))
|
||||||
else:
|
else:
|
||||||
self._logger.info("{0} : No media found for {1}".format(self._name, h2))
|
self._logger.info("{0} : No media found for {1}".format(self._name, h2))
|
||||||
|
try:
|
||||||
|
page = self._request.get(img_src.replace("_q", ""))
|
||||||
|
if page.status_code == 200:
|
||||||
|
self._logger.info("{0} : Get image for media featured : {1}".format(self._name, img_src.replace("_q", "")))
|
||||||
|
media = self._addOrUpdateMedia(img_src.replace("_q", ""), page)
|
||||||
|
if media["id"] != "":
|
||||||
|
self._addOrUpdateFeaturedMedia(soup)
|
||||||
|
else:
|
||||||
|
self._logger.error("{0} : Connection error with status code for get image for featured media : {1}".format(self._name, page.status_code))
|
||||||
|
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||||
|
except ConnectionError as err:
|
||||||
|
self._logger.error("{0} : Connection error for get to image for featured media : {1}".format(self._name, err))
|
||||||
|
exit(1)
|
||||||
|
except Exception as err:
|
||||||
|
self._logger.error("{0} : Exception error for get to image media featured : {1}".format(self._name, err))
|
||||||
else:
|
else:
|
||||||
self._logger.error("{0} : Connection error with status code for search featured media: {1}".format(self._name, page.status_code))
|
self._logger.error("{0} : Connection error with status code for search featured media: {1}".format(self._name, page.status_code))
|
||||||
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||||
|
Reference in New Issue
Block a user