From 62beefa818c75c20b6941389bb197051554a5d41 Mon Sep 17 00:00:00 2001 From: Noah Date: Tue, 25 Apr 2023 22:46:14 +0200 Subject: [PATCH] [extractor/pornhub] Set access cookies to fix extraction (#6685) Closes #4299 Authored by: Schmoaaaaah, arobase-che Co-authored-by: Noah Co-authored-by: ache --- yt_dlp/extractor/pornhub.py | 11 +++++++++-- 1 file 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)