[extractor/common] Allow passing more parameters to _search_json_ld

This commit is contained in:
Yen Chi Hsuan 2016-01-16 20:45:36 +08:00
parent 6be16ed24b
commit 0b26ba3fc8

View File

@ -763,13 +763,13 @@ def _twitter_search_player(self, html):
return self._html_search_meta('twitter:player', html, return self._html_search_meta('twitter:player', html,
'twitter card player') 'twitter card player')
def _search_json_ld(self, html, video_id, fatal=True): def _search_json_ld(self, html, video_id, **kwargs):
json_ld = self._search_regex( json_ld = self._search_regex(
r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>.+?)</script>', r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>.+?)</script>',
html, 'JSON-LD', fatal=fatal, group='json_ld') html, 'JSON-LD', group='json_ld', **kwargs)
if not json_ld: if not json_ld:
return {} return {}
return self._json_ld(json_ld, video_id, fatal=fatal) return self._json_ld(json_ld, video_id, fatal=kwargs.get('fatal', True))
def _json_ld(self, json_ld, video_id, fatal=True): def _json_ld(self, json_ld, video_id, fatal=True):
if isinstance(json_ld, compat_str): if isinstance(json_ld, compat_str):