Skip to content

Commit

Permalink
Turboimagehost - galleries - fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
arebokert committed Jan 18, 2025
1 parent 88f8e84 commit 75bec39
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions gallery_dl/extractor/imagehosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,32 @@ def get_info(self, page):
url = text.extract(page, 'src="', '"', page.index("<img "))[0]
return url, url


class TurboimagehostGalleryExtractor(ImagehostImageExtractor):
"""Extractor for image galleries from turboimagehost.com"""
category = "turboimagehost"
subcategory = "gallery"
pattern = r"(?:https?://)?((?:www\.)?turboimagehost\.com/album/(\d+)/([^/?#]*))"
pattern = (r"(?:https?://)?((?:www\.)?turboimagehost\.com"
r"/album/(\d+)/([^/?#]*))")
example = "https://www.turboimagehost.com/album/12345/gallery_name"

def __init__(self, match):
ImagehostImageExtractor.__init__(self, match)

self.gallery_id = match.group(2)
self.gallery_name = match.group(3)
self.base_url = f"https://www.turboimagehost.com/album/{self.gallery_id}/{self.gallery_name}"
self.base_url = "https://www.turboimagehost.com/album/{}/{}".format(
self.gallery_id, self.gallery_name
)
self.page_url = self.base_url

def items(self):
page = 1

while True:
self.log.debug(f"Fetching page number {page}: {self.page_url}")
self.log.debug(
"Fetching page number {}: {}".format(page, self.page_url)
)
response = self.request(self.page_url)
page_content = response.text

Expand All @@ -316,15 +322,19 @@ def items(self):
if page == 1:
self.log.info("No images found in gallery, exiting...")
else:
self.log.debug(f"No thumbnails found on page number {page}, the page probably doesn't exist, exiting...")
self.log.debug(
"No thumbnails found on page number {}, "
"the page probably doesn't "
"exist, exiting...".format(page)
)
break

for image_page_url in thumbnails:
data = {"_extractor": TurboimagehostImageExtractor}
yield Message.Queue, image_page_url, data

page += 1
self.page_url = f"{self.base_url}?p={page}"
self.page_url = "{}?p={}".format(self.base_url, page)

def _extract_image_pages(self, page_content):
thumbnails = []
Expand All @@ -340,6 +350,7 @@ def _extract_image_pages(self, page_content):
thumbnails.append(href)
return thumbnails


class ViprImageExtractor(ImagehostImageExtractor):
"""Extractor for single images from vipr.im"""
category = "vipr"
Expand Down

0 comments on commit 75bec39

Please sign in to comment.