fixed try_get util
This commit is contained in:
parent
889005bab3
commit
6530f90d24
|
@ -1984,6 +1984,7 @@ def get_elements_by_attribute(attribute, value, html, escape_value=True):
|
||||||
|
|
||||||
class HTMLAttributeParser(compat_HTMLParser):
|
class HTMLAttributeParser(compat_HTMLParser):
|
||||||
"""Trivial HTML parser to gather the attributes for a single element"""
|
"""Trivial HTML parser to gather the attributes for a single element"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.attrs = {}
|
self.attrs = {}
|
||||||
compat_HTMLParser.__init__(self)
|
compat_HTMLParser.__init__(self)
|
||||||
|
@ -2378,6 +2379,7 @@ class GeoRestrictedError(ExtractorError):
|
||||||
This exception may be thrown when a video is not available from your
|
This exception may be thrown when a video is not available from your
|
||||||
geographic location due to geographic restrictions imposed by a website.
|
geographic location due to geographic restrictions imposed by a website.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, msg, countries=None):
|
def __init__(self, msg, countries=None):
|
||||||
super(GeoRestrictedError, self).__init__(msg, expected=True)
|
super(GeoRestrictedError, self).__init__(msg, expected=True)
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
@ -3999,7 +4001,7 @@ def try_get(src, getter, expected_type=None):
|
||||||
except (AttributeError, KeyError, TypeError, IndexError):
|
except (AttributeError, KeyError, TypeError, IndexError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if expected_type is None or isinstance(v, expected_type):
|
if (expected_type is None or isinstance(v, expected_type)) and v is not None:
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue