import math
import operator
import re
-import urllib.request
from .common import InfoExtractor
from .openload import PhantomJSwrapper
-from ..compat import compat_HTTPError, compat_str
+from ..compat import compat_str
+from ..networking import Request
+from ..networking.exceptions import HTTPError
from ..utils import (
NO_DEFAULT,
ExtractorError,
r'document\.cookie\s*=\s*["\']RNKEY=',
r'document\.location\.reload\(true\)')):
url_or_request = args[0]
- url = (url_or_request.get_full_url()
- if isinstance(url_or_request, urllib.request.Request)
+ url = (url_or_request.url
+ if isinstance(url_or_request, Request)
else url_or_request)
phantom = PhantomJSwrapper(self, required_version='2.0')
phantom.get(url, html=webpage)
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, 'accessAgeDisclaimerUK', '1')
+ self._set_cookie(host, 'accessPH', '1')
+
def _login(self, host):
if self._logged_in:
return
def is_logged(webpage):
return any(re.search(p, webpage) for p in (
- r'class=["\']signOut',
- r'>Sign\s+[Oo]ut\s*<'))
+ r'id="profileMenuDropdown"',
+ r'class="ph-icon-logout"'))
if is_logged(login_page):
self._logged_in = True
login_form = self._hidden_inputs(login_page)
login_form.update({
- 'username': username,
+ 'email': username,
'password': password,
})
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)
continue
add_format(video_url)
- # field_preference is unnecessary here, but kept for code-similarity with youtube-dl
- self._sort_formats(
- formats, field_preference=('height', 'width', 'fps', 'format_id'))
-
model_profile = self._search_json(
r'var\s+MODEL_PROFILE\s*=', webpage, 'model profile', video_id, fatal=False)
video_uploader = self._html_search_regex(
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})
base_url, item_id, note, query={'page': num})
def is_404(e):
- return isinstance(e.cause, compat_HTTPError) and e.cause.code == 404
+ return isinstance(e.cause, HTTPError) and e.cause.status == 404
base_url = url
has_page = page is not None
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)
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)