diff options
Diffstat (limited to 'gallery_dl/extractor/pornpics.py')
| -rw-r--r-- | gallery_dl/extractor/pornpics.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/gallery_dl/extractor/pornpics.py b/gallery_dl/extractor/pornpics.py index 83f3064..863ef3b 100644 --- a/gallery_dl/extractor/pornpics.py +++ b/gallery_dl/extractor/pornpics.py @@ -20,10 +20,6 @@ class PornpicsExtractor(Extractor): root = "https://www.pornpics.com" request_interval = (0.5, 1.5) - def __init__(self, match): - super().__init__(match) - self.item = match.group(1) - def items(self): for gallery in self.galleries(): gallery["_extractor"] = PornpicsGalleryExtractor @@ -34,9 +30,11 @@ class PornpicsExtractor(Extractor): # fetch first 20 galleries from HTML # since '"offset": 0' does not return a JSON response page = self.request(url).text - for path in text.extract_iter( + for href in text.extract_iter( page, 'class="rel-link" href="', '"'): - yield {"g_url": self.root + path} + if href[0] == "/": + href = self.root + href + yield {"g_url": href} del page params = {"offset": 20} @@ -60,12 +58,12 @@ class PornpicsExtractor(Extractor): class PornpicsGalleryExtractor(PornpicsExtractor, GalleryExtractor): """Extractor for pornpics galleries""" - pattern = BASE_PATTERN + r"(/galleries/(?:[^/?#]+-)?(\d+))" + pattern = BASE_PATTERN + r"/galleries/((?:[^/?#]+-)?(\d+))" example = "https://www.pornpics.com/galleries/TITLE-12345/" def __init__(self, match): - PornpicsExtractor.__init__(self, match) - self.gallery_id = match.group(2) + url = "{}/galleries/{}/".format(self.root, match.group(1)) + GalleryExtractor.__init__(self, match, url) items = GalleryExtractor.items @@ -73,7 +71,7 @@ class PornpicsGalleryExtractor(PornpicsExtractor, GalleryExtractor): extr = text.extract_from(page) return { - "gallery_id": text.parse_int(self.gallery_id), + "gallery_id": text.parse_int(self.groups[1]), "slug" : extr("/galleries/", "/").rpartition("-")[0], "title" : text.unescape(extr("<h1>", "<")), "channel" : text.split_html(extr(">Channel: ", '</div>')), @@ -100,7 +98,7 @@ class PornpicsTagExtractor(PornpicsExtractor): example = "https://www.pornpics.com/tags/TAGS/" def galleries(self): - url = "{}/tags/{}/".format(self.root, self.item) + url = "{}/tags/{}/".format(self.root, self.groups[0]) return self._pagination(url) @@ -113,7 +111,7 @@ class PornpicsSearchExtractor(PornpicsExtractor): def galleries(self): url = self.root + "/search/srch.php" params = { - "q" : self.item.replace("-", " "), + "q" : self.groups[0].replace("-", " "), "lang" : "en", "offset": 0, } |
