aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoah <nkempers@outlook.de>2023-04-25 22:46:14 +0200
committerGitHub <noreply@github.com>2023-04-25 20:46:14 +0000
commit62beefa818c75c20b6941389bb197051554a5d41 (patch)
tree7f2791d1b38c382aad4b677ea0b3f8995c31083a
parent0c4e0fbcade0fc92d14c2a6d63e360fe067f6192 (diff)
downloadhypervideo-pre-62beefa818c75c20b6941389bb197051554a5d41.tar.lz
hypervideo-pre-62beefa818c75c20b6941389bb197051554a5d41.tar.xz
hypervideo-pre-62beefa818c75c20b6941389bb197051554a5d41.zip
[extractor/pornhub] Set access cookies to fix extraction (#6685)
Closes #4299 Authored by: Schmoaaaaah, arobase-che Co-authored-by: Noah <nkempers@outlook.de> Co-authored-by: ache <ache@ache.one>
-rw-r--r--yt_dlp/extractor/pornhub.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/yt_dlp/extractor/pornhub.py b/yt_dlp/extractor/pornhub.py
index 5d8d7c100..2f5a572a5 100644
--- a/yt_dlp/extractor/pornhub.py
+++ b/yt_dlp/extractor/pornhub.py
@@ -58,6 +58,11 @@ class PornHubBaseIE(InfoExtractor):
def _real_initialize(self):
self._logged_in = False
+ def _set_age_cookies(self, host):
+ self._set_cookie(host, 'age_verified', '1')
+ self._set_cookie(host, 'accessAgeDisclaimerPH', '1')
+ self._set_cookie(host, 'accessPH', '1')
+
def _login(self, host):
if self._logged_in:
return
@@ -267,8 +272,7 @@ class PornHubIE(PornHubBaseIE):
video_id = mobj.group('id')
self._login(host)
-
- self._set_cookie(host, 'age_verified', '1')
+ self._set_age_cookies(host)
def dl_webpage(platform):
self._set_cookie(host, 'platform', platform)
@@ -569,6 +573,7 @@ class PornHubUserIE(PornHubPlaylistBaseIE):
mobj = self._match_valid_url(url)
user_id = mobj.group('id')
videos_url = '%s/videos' % mobj.group('url')
+ self._set_age_cookies(mobj.group('host'))
page = self._extract_page(url)
if page:
videos_url = update_url_query(videos_url, {'page': page})
@@ -633,6 +638,7 @@ class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE):
item_id = mobj.group('id')
self._login(host)
+ self._set_age_cookies(host)
return self.playlist_result(self._entries(url, host, item_id), item_id)
@@ -812,5 +818,6 @@ class PornHubPlaylistIE(PornHubPlaylistBaseIE):
item_id = mobj.group('id')
self._login(host)
+ self._set_age_cookies(host)
return self.playlist_result(self._entries(mobj.group('url'), host, item_id), item_id)