Merge pull request #288 from gudata/master
fix images url and remove trailing spaces
This commit is contained in:
commit
e016ad340b
2 changed files with 27 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,3 +11,4 @@ Books/
|
||||||
cookies.json
|
cookies.json
|
||||||
*.log
|
*.log
|
||||||
*.txt
|
*.txt
|
||||||
|
*.code-workspace
|
||||||
|
|
|
||||||
|
|
@ -812,10 +812,19 @@ class SafariBooks:
|
||||||
self.chapter_title = next_chapter["title"]
|
self.chapter_title = next_chapter["title"]
|
||||||
self.filename = next_chapter["filename"]
|
self.filename = next_chapter["filename"]
|
||||||
|
|
||||||
# Images
|
asset_base_url = next_chapter['asset_base_url']
|
||||||
|
api_v2_detected = False
|
||||||
|
if 'v2' in next_chapter['content']:
|
||||||
|
asset_base_url = SAFARI_BASE_URL + "/api/v2/epubs/urn:orm:book:{}/files".format(self.book_id)
|
||||||
|
api_v2_detected = True
|
||||||
|
|
||||||
if "images" in next_chapter and len(next_chapter["images"]):
|
if "images" in next_chapter and len(next_chapter["images"]):
|
||||||
self.images.extend(urljoin(next_chapter['asset_base_url'], img_url)
|
for img_url in next_chapter['images']:
|
||||||
for img_url in next_chapter['images'])
|
if api_v2_detected:
|
||||||
|
self.images.append(asset_base_url + '/' + img_url)
|
||||||
|
else:
|
||||||
|
self.images.append(urljoin(next_chapter['asset_base_url'], img_url))
|
||||||
|
|
||||||
|
|
||||||
# Stylesheets
|
# Stylesheets
|
||||||
self.chapter_stylesheets = []
|
self.chapter_stylesheets = []
|
||||||
|
|
@ -863,6 +872,7 @@ class SafariBooks:
|
||||||
self.css_done_queue.put(1)
|
self.css_done_queue.put(1)
|
||||||
self.display.state(len(self.css), self.css_done_queue.qsize())
|
self.display.state(len(self.css), self.css_done_queue.qsize())
|
||||||
|
|
||||||
|
|
||||||
def _thread_download_images(self, url):
|
def _thread_download_images(self, url):
|
||||||
image_name = url.split("/")[-1]
|
image_name = url.split("/")[-1]
|
||||||
image_path = os.path.join(self.images_path, image_name)
|
image_path = os.path.join(self.images_path, image_name)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue