[pornpics] prevent redirect when retrieving gallery page

This commit is contained in:
Mike Fährmann
2025-01-26 22:33:42 +01:00
parent 65863239a0
commit b201f91d8d

View File

@@ -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
@@ -60,12 +56,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 +69,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:&nbsp;", '</div>')),
@@ -100,7 +96,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 +109,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,
}