- for line in self._search_regex( 'var flashvars = ({[^}]+})', webpage, 'flashvars').splitlines():
- if '+' not in line and '(' not in line and ')' not in line:
- player_info += line
- player_info = self._parse_json(js_to_json(player_info), video_id)
- video_id = player_info['id']
- player_type = player_info['playerType']
+ flash_vars = self._search_regex('var flashvars = ({[^}]+})', webpage, 'flashvars', None)
+ if flash_vars is not None:
+ for line in flash_vars.splitlines():
+ if '+' not in line and '(' not in line and ')' not in line:
+ player_info += line
+ player_info = self._parse_json(player_info, video_id, js_to_json, False)
+ if player_info is not None:
+ for key in self._api_vars:
+ if key in player_info:
+ self._api_vars[key] = player_info[key]
+
+ player_json_data = self._download_json(
+ 'https://shahid.mbc.net/arContent/getPlayerContent-param-.id-' + video_id + '.type-' + self._api_vars['type'] + '.html',
+ video_id
+ )['data']
+ if 'url' in player_json_data:
+ m3u8_url = player_json_data['url']
+ else:
+ for error in player_json_data['error'].values():
+ raise ExtractorError(error)
+ formats = self._extract_m3u8_formats(m3u8_url, video_id)