1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

merge #5016: [zzup] add 'gallery' extractor (#4517, #4604, #4659, #4863)

This commit is contained in:
Mike Fährmann 2024-01-05 21:25:46 +01:00
commit c158927c38
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 72 additions and 0 deletions

View File

@ -178,6 +178,7 @@ modules = [
"xhamster",
"xvideos",
"zerochan",
"zzup",
"booru",
"moebooru",
"foolfuuka",

View File

@ -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
test/results/zzup.py Normal file
View File

@ -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",
},
)