# -*- 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. """Extractors for https://zzup.com/""" from .common import GalleryExtractor from .. import text class ZzupGalleryExtractor(GalleryExtractor): category = "zzup" directory_fmt = ("{category}", "{title}") filename_fmt = "{num:>03}.{extension}" archive_fmt = "{slug}_{num}" root = "https://zzup.com" pattern = (r"(?:https?://)?(up\.|w+\.)?zzup\.com(/(?:viewalbum|content)" r"/[\w=]+/([^/?#]+)/[\w=]+)/(?:index|page-\d+)\.html") example = "https://zzup.com/content/xyz=/12345_TITLE/123=/index.html" def __init__(self, match): subdomain, path, self.slug = match.groups() if subdomain == "up.": self.root = "https://up.zzup.com" self.images = self.images_v2 url = f"{self.root}{path}/index.html" GalleryExtractor.__init__(self, match, url) def metadata(self, page): return { "slug" : self.slug, "title": text.unescape(text.extr( page, "", ""))[:-11], } def images(self, page): path = text.extr(page, 'class="picbox">05}{p2}", None) for i in range(1, count + 1)] def images_v2(self, page): base = f"{self.root}/showimage/" results = [] while True: for path in text.extract_iter( page, ' class="picbox">