Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PornHub] Rename the age verification cookie #31916

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions youtube_dl/extractor/pornhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ def dl(*args, **kwargs):
def _real_initialize(self):
self._logged_in = False

def _set_age_cookies(self, host):
# The age verification cookie may have a different name based on the location.
# Setting multiple cookies doesn't seem to be big deal so we prefer that solution instead
# of guessing the right cookie out of an IP we don't currently have.
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
Expand Down Expand Up @@ -264,11 +272,9 @@ def _real_extract(self, url):
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)
return self._download_webpage(
'https://www.%s/view_video.php?viewkey=%s' % (host, video_id),
video_id, 'Downloading %s webpage' % platform)
Expand Down Expand Up @@ -564,6 +570,7 @@ def _real_extract(self, url):
mobj = re.match(self._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})
Expand Down Expand Up @@ -628,6 +635,7 @@ def _real_extract(self, url):
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)

Expand Down