|
|
@ -19,7 +19,6 @@ from ..compat import (
|
|
|
|
compat_etree_Element,
|
|
|
|
compat_etree_Element,
|
|
|
|
compat_etree_fromstring,
|
|
|
|
compat_etree_fromstring,
|
|
|
|
compat_getpass,
|
|
|
|
compat_getpass,
|
|
|
|
compat_integer_types,
|
|
|
|
|
|
|
|
compat_http_client,
|
|
|
|
compat_http_client,
|
|
|
|
compat_os_name,
|
|
|
|
compat_os_name,
|
|
|
|
compat_str,
|
|
|
|
compat_str,
|
|
|
@ -79,6 +78,7 @@ from ..utils import (
|
|
|
|
urljoin,
|
|
|
|
urljoin,
|
|
|
|
url_basename,
|
|
|
|
url_basename,
|
|
|
|
url_or_none,
|
|
|
|
url_or_none,
|
|
|
|
|
|
|
|
variadic,
|
|
|
|
xpath_element,
|
|
|
|
xpath_element,
|
|
|
|
xpath_text,
|
|
|
|
xpath_text,
|
|
|
|
xpath_with_ns,
|
|
|
|
xpath_with_ns,
|
|
|
@ -628,14 +628,10 @@ class InfoExtractor(object):
|
|
|
|
assert isinstance(err, compat_urllib_error.HTTPError)
|
|
|
|
assert isinstance(err, compat_urllib_error.HTTPError)
|
|
|
|
if expected_status is None:
|
|
|
|
if expected_status is None:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
if isinstance(expected_status, compat_integer_types):
|
|
|
|
|
|
|
|
return err.code == expected_status
|
|
|
|
|
|
|
|
elif isinstance(expected_status, (list, tuple)):
|
|
|
|
|
|
|
|
return err.code in expected_status
|
|
|
|
|
|
|
|
elif callable(expected_status):
|
|
|
|
elif callable(expected_status):
|
|
|
|
return expected_status(err.code) is True
|
|
|
|
return expected_status(err.code) is True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
assert False
|
|
|
|
return err.code in variadic(expected_status)
|
|
|
|
|
|
|
|
|
|
|
|
def _request_webpage(self, url_or_request, video_id, note=None, errnote=None, fatal=True, data=None, headers={}, query={}, expected_status=None):
|
|
|
|
def _request_webpage(self, url_or_request, video_id, note=None, errnote=None, fatal=True, data=None, headers={}, query={}, expected_status=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -1207,8 +1203,7 @@ class InfoExtractor(object):
|
|
|
|
[^>]+?content=(["\'])(?P<content>.*?)\2''' % re.escape(prop)
|
|
|
|
[^>]+?content=(["\'])(?P<content>.*?)\2''' % re.escape(prop)
|
|
|
|
|
|
|
|
|
|
|
|
def _og_search_property(self, prop, html, name=None, **kargs):
|
|
|
|
def _og_search_property(self, prop, html, name=None, **kargs):
|
|
|
|
if not isinstance(prop, (list, tuple)):
|
|
|
|
prop = variadic(prop)
|
|
|
|
prop = [prop]
|
|
|
|
|
|
|
|
if name is None:
|
|
|
|
if name is None:
|
|
|
|
name = 'OpenGraph %s' % prop[0]
|
|
|
|
name = 'OpenGraph %s' % prop[0]
|
|
|
|
og_regexes = []
|
|
|
|
og_regexes = []
|
|
|
@ -1238,8 +1233,7 @@ class InfoExtractor(object):
|
|
|
|
return self._og_search_property('url', html, **kargs)
|
|
|
|
return self._og_search_property('url', html, **kargs)
|
|
|
|
|
|
|
|
|
|
|
|
def _html_search_meta(self, name, html, display_name=None, fatal=False, **kwargs):
|
|
|
|
def _html_search_meta(self, name, html, display_name=None, fatal=False, **kwargs):
|
|
|
|
if not isinstance(name, (list, tuple)):
|
|
|
|
name = variadic(name)
|
|
|
|
name = [name]
|
|
|
|
|
|
|
|
if display_name is None:
|
|
|
|
if display_name is None:
|
|
|
|
display_name = name[0]
|
|
|
|
display_name = name[0]
|
|
|
|
return self._html_search_regex(
|
|
|
|
return self._html_search_regex(
|
|
|
|