[vidzi] Introduce intermediate json_data variable

It makes it easier to debug in case of problems and it also
makes the code much easier to read since the three distinct
things done are now explicit separated as three statements.
This commit is contained in:
Håkon Løvdal 2018-06-12 20:19:51 +02:00
parent 734d461ca0
commit 2485f89201

View File

@ -50,12 +50,12 @@ class VidziIE(InfoExtractor):
decode_packed_codes(mobj.group(0)).replace('\\\'', '\'') decode_packed_codes(mobj.group(0)).replace('\\\'', '\'')
for mobj in re.finditer(PACKED_CODES_RE, webpage)]) for mobj in re.finditer(PACKED_CODES_RE, webpage)])
for num, code in enumerate(codes, 1): for num, code in enumerate(codes, 1):
jwplayer_data = self._parse_json( json_data = self._search_regex(
self._search_regex( r'setup\(([^)]+)\)', code, 'jwplayer data',
r'setup\(([^)]+)\)', code, 'jwplayer data', default=NO_DEFAULT if num == len(codes) else '{}')
default=NO_DEFAULT if num == len(codes) else '{}'), json_data = re.sub(r'\s*\+\s*window\[.+?\]', '', json_data)
video_id, transform_source=lambda s: js_to_json( # print 'json_data: {0}'.format(json_data)
re.sub(r'\s*\+\s*window\[.+?\]', '', s))) jwplayer_data = self._parse_json(json_data, video_id, transform_source=js_to_json)
if jwplayer_data: if jwplayer_data:
break break