[GameStar] handle JSON containing control chars

This commit is contained in:
aeph6Ee0 2017-04-10 22:47:24 +02:00
parent 1730878167
commit fef3a29f92
2 changed files with 3 additions and 3 deletions

View File

@ -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:

View File

@ -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')