- player_info = ''
- 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]
+ api_vars = {
+ 'id': video_id,
+ 'type': 'player',
+ 'url': 'http://api.shahid.net/api/v1_1',
+ 'playerType': 'episode',
+ }
+
+ flashvars = self._search_regex(
+ r'var\s+flashvars\s*=\s*({[^}]+})', webpage, 'flashvars', default=None)
+ if flashvars:
+ for key in api_vars.keys():
+ value = self._search_regex(
+ r'\b%s\s*:\s*(?P<q>["\'])(?P<value>.+?)(?P=q)' % key,
+ flashvars, 'type', default=None, group='value')
+ if value:
+ api_vars[key] = value
+
+ player = self._download_json(
+ 'https://shahid.mbc.net/arContent/getPlayerContent-param-.id-%s.type-%s.html'
+ % (video_id, api_vars['type']), video_id, 'Downloading player JSON')