- 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')
-
- formats = self._extract_m3u8_formats(player['url'], video_id, 'mp4')
-
- video = self._download_json(
- '%s/%s/%s?%s' % (
- api_vars['url'], api_vars['playerType'], api_vars['id'],
- compat_urllib_parse.urlencode({
- 'apiKey': 'sh@hid0nlin3',
- 'hash': 'b2wMCTHpSmyxGqQjJFOycRmLSex+BpTK/ooxy6vHaqs=',
- })),
- video_id, 'Downloading video JSON')
-
- video = video[api_vars['playerType']]
+ video = self._get_api_data(self._download_json(
+ 'http://api.shahid.net/api/v1_1/%s/%s' % (page_type, video_id),
+ video_id, 'Downloading video JSON', query={
+ 'apiKey': 'sh@hid0nlin3',
+ 'hash': 'b2wMCTHpSmyxGqQjJFOycRmLSex+BpTK/ooxy6vHaqs=',
+ }))[page_type]