Compare commits

...

2 Commits

Author SHA1 Message Date
Jason
9e7b5d9506
Merge 43e7dd46dd into 0153b387e5 2024-06-14 09:54:20 +00:00
Jason23347
43e7dd46dd Always set the age check cookie (31916) 2023-09-11 09:19:53 +08:00

View File

@ -60,6 +60,14 @@ class PornHubBaseIE(InfoExtractor):
def _real_initialize(self): def _real_initialize(self):
self._logged_in = False 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): def _login(self, host):
if self._logged_in: if self._logged_in:
return return
@ -264,11 +272,9 @@ class PornHubIE(PornHubBaseIE):
video_id = mobj.group('id') video_id = mobj.group('id')
self._login(host) self._login(host)
self._set_age_cookies(host)
self._set_cookie(host, 'age_verified', '1')
def dl_webpage(platform): def dl_webpage(platform):
self._set_cookie(host, 'platform', platform)
return self._download_webpage( return self._download_webpage(
'https://www.%s/view_video.php?viewkey=%s' % (host, video_id), 'https://www.%s/view_video.php?viewkey=%s' % (host, video_id),
video_id, 'Downloading %s webpage' % platform) video_id, 'Downloading %s webpage' % platform)
@ -564,6 +570,7 @@ class PornHubUserIE(PornHubPlaylistBaseIE):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
user_id = mobj.group('id') user_id = mobj.group('id')
videos_url = '%s/videos' % mobj.group('url') videos_url = '%s/videos' % mobj.group('url')
self._set_age_cookies(mobj.group('host'))
page = self._extract_page(url) page = self._extract_page(url)
if page: if page:
videos_url = update_url_query(videos_url, {'page': page}) videos_url = update_url_query(videos_url, {'page': page})
@ -628,6 +635,7 @@ class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE):
item_id = mobj.group('id') item_id = mobj.group('id')
self._login(host) self._login(host)
self._set_age_cookies(host)
return self.playlist_result(self._entries(url, host, item_id), item_id) return self.playlist_result(self._entries(url, host, item_id), item_id)