summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/pornhub.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/pornhub.py')
-rw-r--r--gallery_dl/extractor/pornhub.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/gallery_dl/extractor/pornhub.py b/gallery_dl/extractor/pornhub.py
index f8497c0..f19e33c 100644
--- a/gallery_dl/extractor/pornhub.py
+++ b/gallery_dl/extractor/pornhub.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2019-2021 Mike Fährmann
+# Copyright 2019-2023 Mike Fährmann
#
# 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
@@ -11,7 +11,6 @@
from .common import Extractor, Message
from .. import text, exception
-
BASE_PATTERN = r"(?:https?://)?(?:[\w-]+\.)?pornhub\.com"
@@ -146,10 +145,20 @@ class PornhubUserExtractor(PornhubExtractor):
data = {"_extractor": PornhubGalleryExtractor}
while True:
- page = self.request(
- url, method="POST", headers=headers, params=params).text
- if not page:
- return
- for gid in text.extract_iter(page, 'id="albumphoto', '"'):
+ response = self.request(
+ url, method="POST", headers=headers, params=params,
+ allow_redirects=False)
+
+ if 300 <= response.status_code < 400:
+ url = "{}{}/photos/{}/ajax".format(
+ self.root, response.headers["location"],
+ self.cat or "public")
+ continue
+
+ gid = None
+ for gid in text.extract_iter(response.text, 'id="albumphoto', '"'):
yield Message.Queue, self.root + "/album/" + gid, data
+ if gid is None:
+ return
+
params["page"] += 1