Skip to content

Commit

Permalink
merge #5016: [zzup] add 'gallery' extractor (#4517, #4604, #4659, #4863)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 5, 2024
2 parents 217fa7f + 0f30136 commit c158927
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"xhamster",
"xvideos",
"zerochan",
"zzup",
"booru",
"moebooru",
"foolfuuka",
Expand Down
40 changes: 40 additions & 0 deletions gallery_dl/extractor/zzup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

from .common import GalleryExtractor
from .. import text


class ZzupGalleryExtractor(GalleryExtractor):
category = "zzup"
directory_fmt = ("{category}", "{title}")
filename_fmt = "{slug}_{num:>03}.{extension}"
archive_fmt = "{slug}_{num}"
root = "https://zzup.com"
pattern = (r"(?:https?://)?(?:www\.)?zzup\.com(/content"
r"/[\w=]+/([^/?#]+)/[\w=]+)/(?:index|page-\d+)\.html")
example = "https://zzup.com/content/xyz=/12345_TITLE/123=/index.html"

def __init__(self, match):
url = "{}/{}/index.html".format(self.root, match.group(1))
GalleryExtractor.__init__(self, match, url)
self.slug = match.group(2)

def metadata(self, page):
return {
"slug" : self.slug,
"title": text.unescape(text.extr(
page, "<title>", "</title>"))[:-11],
}

def images(self, page):
path = text.extr(page, 'class="picbox"><a target="_blank" href="', '"')
count = text.parse_int(text.extr(path, "-pics-", "-mirror"))
page = self.request(self.root + path).text
url = self.root + text.extr(page, '\n<a href="', '"')
p1, _, p2 = url.partition("/image0")
ufmt = p1 + "/image{:>05}" + p2[4:]
return [(ufmt.format(num), None) for num in range(1, count + 1)]
31 changes: 31 additions & 0 deletions test/results/zzup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

from gallery_dl.extractor import zzup


__tests__ = (
{
"#url" : "https://zzup.com/content/NjM=/MetArt_20080206_viki_c_sensazioni_by_ingret/OTE=/index.html",
"#category": ("", "zzup", "gallery"),
"#class" : zzup.ZzupGalleryExtractor,
"#pattern" : r"https://zzup\.com/MjAxNjc3OTIyMjE5Nzk=/showimage/zzup-8769086487/image00\d\d\d-5896498214-1-9689595623/MetArt-20080206_viki_c_sensazioni_by_ingret/9879560327/zzup.com.jpg",

"slug" : "MetArt_20080206_viki_c_sensazioni_by_ingret",
"title" : "MetArt 20080206 viki c sensazioni by ingret",
"num" : int,
"count" : 135,
},

{
"#url" : "https://zzup.com/content/MTc2MDYxMw==/Courtesan/NDA=/page-1.html",
"#category": ("", "zzup", "gallery"),
"#class" : zzup.ZzupGalleryExtractor,
"#pattern" : r"https://zzup.com/MjAxNjc3OTIyMjE5Nzk=/showimage/zzup-8769086487/image000\d\d-5896498214-40-9689595623/Courtesan/9879560327/zzup.com.jpg",
},

)

0 comments on commit c158927

Please sign in to comment.