- match_id = self._match_id(url)
- webpage = self._download_webpage(url, match_id)
-
- episode_id = self._html_search_regex(r"commentControls\('#comment-([0-9]+)'\)", webpage, 'episode id', match_id, False)
-
- self.report_extraction(episode_id)
-
- title = self._html_search_regex(r'<title>([^<]+)</title>', webpage, 'episode title', self._og_search_title(webpage), False)
- thumbnail = self._og_search_thumbnail(webpage)
- description = self._og_search_description(webpage)
- creator = self._html_search_regex(r'<h3>Latest (.+) Gear</h3>', webpage, 'site', 'Rooster Teeth', False)
- series = self._html_search_regex(r'<h2>More ([^<]+)</h2>', webpage, 'series', fatal=False)
- episode = self._html_search_regex(r'<title>([^<]+)</title>', webpage, 'episode title', fatal=False)
-
- if '<div class="non-sponsor">' in webpage:
- self.raise_login_required('%s is only available for FIRST members' % title)
-
- if '<div class="golive-gate">' in webpage:
- self.raise_login_required('%s is not available yet' % title)
-
- formats = self._extract_m3u8_formats(self._html_search_regex(r"file: '(.+?)m3u8'", webpage, 'm3u8 url') + 'm3u8', episode_id, ext='mp4')
+ display_id = self._match_id(url)
+ api_episode_url = self._EPISODE_BASE_URL + display_id
+
+ try:
+ m3u8_url = self._download_json(
+ api_episode_url + '/videos', display_id,
+ 'Downloading video JSON metadata')['data'][0]['attributes']['url']
+ except ExtractorError as e:
+ if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
+ if self._parse_json(e.cause.read().decode(), display_id).get('access') is False:
+ self.raise_login_required(
+ '%s is only available for FIRST members' % display_id)
+ raise
+
+ formats = self._extract_m3u8_formats(
+ m3u8_url, display_id, 'mp4', 'm3u8_native', m3u8_id='hls')