fixed try_get util

This commit is contained in:
Laura Liberda 2020-12-10 01:32:45 +01:00
parent 889005bab3
commit 6530f90d24

View file

@ -1984,6 +1984,7 @@ def get_elements_by_attribute(attribute, value, html, escape_value=True):
class HTMLAttributeParser(compat_HTMLParser):
"""Trivial HTML parser to gather the attributes for a single element"""
def __init__(self):
self.attrs = {}
compat_HTMLParser.__init__(self)
@ -2378,6 +2379,7 @@ class GeoRestrictedError(ExtractorError):
This exception may be thrown when a video is not available from your
geographic location due to geographic restrictions imposed by a website.
"""
def __init__(self, msg, countries=None):
super(GeoRestrictedError, self).__init__(msg, expected=True)
self.msg = msg
@ -3999,7 +4001,7 @@ def try_get(src, getter, expected_type=None):
except (AttributeError, KeyError, TypeError, IndexError):
pass
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