[GameStar] handle JSON containing control chars
This commit is contained in:
parent
1730878167
commit
fef3a29f92
@ -665,11 +665,11 @@ class InfoExtractor(object):
|
||||
return self._parse_json(
|
||||
json_string, video_id, transform_source=transform_source, fatal=fatal)
|
||||
|
||||
def _parse_json(self, json_string, video_id, transform_source=None, fatal=True):
|
||||
def _parse_json(self, json_string, video_id, transform_source=None, fatal=True, strict=True):
|
||||
if transform_source:
|
||||
json_string = transform_source(json_string)
|
||||
try:
|
||||
return json.loads(json_string)
|
||||
return json.loads(json_string, strict=strict)
|
||||
except ValueError as ve:
|
||||
errmsg = '%s: Failed to parse JSON ' % video_id
|
||||
if fatal:
|
||||
|
@ -35,7 +35,7 @@ class GameStarIE(InfoExtractor):
|
||||
# while _search_json_ld finds only the first one
|
||||
json_ld = self._parse_json(self._search_regex(
|
||||
r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>[^<]+VideoObject[^<]+)</script>',
|
||||
webpage, 'JSON-LD', group='json_ld'), video_id)
|
||||
webpage, 'JSON-LD', group='json_ld'), video_id, strict=False)
|
||||
info_dict = self._json_ld(json_ld, video_id)
|
||||
info_dict['title'] = remove_end(info_dict['title'], ' - GameStar')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user