Skip to content

Commit

Permalink
merge #6855: [turboimagehost] add support for galleries
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 19, 2025
2 parents 0f50dd1 + 556fbb1 commit f867e69
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>Turboimagehost</td>
<td>https://www.turboimagehost.com/</td>
<td>individual Images</td>
<td>Galleries, individual Images</td>
<td></td>
</tr>
<tr>
Expand Down
28 changes: 28 additions & 0 deletions gallery_dl/extractor/imagehosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,34 @@ def get_info(self, page):
return url, url


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

def items(self):
data = {"_extractor": TurboimagehostImageExtractor}
params = {"p": 1}

while True:
page = self.request(self.page_url, params=params).text

if params["p"] == 1 and \
"Requested gallery don`t exist on our website." in page:
raise exception.NotFoundError("gallery")

thumb_url = None
for thumb_url in text.extract_iter(page, '"><a href="', '"'):
yield Message.Queue, thumb_url, data
if thumb_url is None:
return

params["p"] += 1


class ViprImageExtractor(ImagehostImageExtractor):
"""Extractor for single images from vipr.im"""
category = "vipr"
Expand Down
10 changes: 10 additions & 0 deletions test/results/turboimagehost.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@
"#sha1_content" : (
"f38b54b17cd7462e687b58d83f00fca88b1b105a",
"0c8768055e4e20e7c7259608b67799171b691140",
"961b25d85b5f5bd18cbe3e847ac55925f14d0286"
),
},

{
"#url" : "https://www.turboimagehost.com/album/344597/testimagegallery",
"#category": ("imagehost", "turboimagehost", "gallery"),
"#class" : imagehosts.TurboimagehostGalleryExtractor,
"#pattern" : imagehosts.TurboimagehostImageExtractor.pattern,
"#sha1_url": "f2d4fe102fdd71dd1f595cdb0c16ce999d6bb19b",
"#count" : 110,
},

)

0 comments on commit f867e69

Please sign in to comment.