1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-06 08:22:56 +01:00

fix(ebook/__init__.py): Leech will now ignore empty image tags (because apparently that's a thing).

feat(ebook/__init__.py): Leech print out more information about the images it is downloading. The number of images in each chapter and the image downloading currently.
This commit is contained in:
Emmanuel Jemeni 2023-02-25 22:32:47 +01:00 committed by David Lynch
parent b1f1c01210
commit 63ac765e41

View file

@ -89,7 +89,15 @@ def chapter_html(story, titleprefix=None, normalize=False):
chapter, titleprefix=title, normalize=normalize))
else:
soup = BeautifulSoup(chapter.contents, 'html5lib')
for count, img in enumerate(soup.find_all('img')):
all_images = soup.find_all('img')
len_of_all_images = len(all_images)
print(f"\nFound {len_of_all_images} images in chapter {i}\n")
for count, img in enumerate(all_images):
if not img.has_attr('src'):
print(f"Image {count} has no src attribute, skipping...")
continue
print(f"Downloading image {count+1} out of {len_of_all_images} from chapter {i}")
img_contents = get_image_from_url(img['src']).read()
chapter.images.append(Image(
path=f"images/ch{i}_leechimage_{count}.png",