[pornhub] fix 'gallery' extractor (#7842)
- update API endpoint - extract and send 'token' parameter
This commit is contained in:
@@ -85,6 +85,7 @@ class PornhubGalleryExtractor(PornhubExtractor):
|
||||
extr = text.extract_from(self.request(url).text)
|
||||
|
||||
title = extr("<title>", "</title>")
|
||||
self._token = extr('name="token" value="', '"')
|
||||
score = extr('<div id="albumGreenBar" style="width:', '"')
|
||||
views = extr('<div id="viewsPhotAlbumCounter">', '<')
|
||||
tags = extr('<div id="photoTagsBox"', '<script')
|
||||
@@ -103,12 +104,12 @@ class PornhubGalleryExtractor(PornhubExtractor):
|
||||
}
|
||||
|
||||
def images(self):
|
||||
url = f"{self.root}/album/show_album_json?album={self.gallery_id}"
|
||||
response = self.request(url)
|
||||
url = f"{self.root}/api/v1/album/{self.gallery_id}/show_album_json"
|
||||
params = {"token": self._token}
|
||||
data = self.request_json(url, params=params)
|
||||
|
||||
if response.content == b"Permission denied":
|
||||
if not (images := data.get("photos")):
|
||||
raise exception.AuthorizationError()
|
||||
images = response.json()
|
||||
key = end = self._first
|
||||
|
||||
results = []
|
||||
|
||||
@@ -35,14 +35,16 @@ __tests__ = (
|
||||
"#url" : "https://www.pornhub.com/album/69606532",
|
||||
"#comment" : "KeyError due to missing image entry (#6299)",
|
||||
"#class" : pornhub.PornhubGalleryExtractor,
|
||||
"#log" : "69606532: Unable to ensure correct file order",
|
||||
"#count" : 6,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.pornhub.com/album/69040172",
|
||||
"#comment" : "404 Error Page Not Found",
|
||||
"#category": ("", "pornhub", "gallery"),
|
||||
"#class" : pornhub.PornhubGalleryExtractor,
|
||||
"#exception": exception.AuthorizationError,
|
||||
"#exception": exception.HttpError,
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user