2 from __future__ import unicode_literals
6 from .brightcove import BrightcoveNewIE
18 class SevenPlusIE(BrightcoveNewIE):
20 _VALID_URL = r'https?://(?:www\.)?7plus\.com\.au/(?P<path>[^?]+\?.*?\bepisode-id=(?P<id>[^&#]+))'
22 'url': 'https://7plus.com.au/MTYS?episode-id=MTYS7-003',
26 'title': 'S7 E3 - Wind Surf',
27 'description': 'md5:29c6a69f21accda7601278f81b46483d',
28 'uploader_id': '5303576322001',
29 'upload_date': '20171201',
30 'timestamp': 1512106377,
31 'series': 'Mighty Ships',
34 'episode': 'Wind Surf',
37 'format': 'bestvideo',
38 'skip_download': True,
41 'url': 'https://7plus.com.au/UUUU?episode-id=AUMS43-001',
42 'only_matching': True,
45 def _real_extract(self, url):
46 path, episode_id = re.match(self._VALID_URL, url).groups()
49 media = self._download_json(
50 'https://videoservice.swm.digital/playback', episode_id, query={
53 'platformType': 'web',
54 'accountId': 5303576322001,
55 'referenceId': 'ref:' + episode_id,
59 except ExtractorError as e:
60 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
61 raise ExtractorError(self._parse_json(
62 e.cause.read().decode(), episode_id)[0]['error_code'], expected=True)
65 for source in media.get('sources', {}):
66 src = source.get('src')
69 source['src'] = update_url_query(src, {'rule': ''})
71 info = self._parse_brightcove_metadata(media, episode_id)
73 content = self._download_json(
74 'https://component-cdn.swm.digital/content/' + path,
78 for item in content.get('items', {}):
79 if item.get('componentData', {}).get('componentType') == 'infoPanel':
80 for src_key, dst_key in [('title', 'title'), ('shortSynopsis', 'description')]:
81 value = item.get(src_key)
84 info['series'] = try_get(
85 item, lambda x: x['seriesLogo']['name'], compat_str)
86 mobj = re.search(r'^S(\d+)\s+E(\d+)\s+-\s+(.+)$', info['title'])
89 'season_number': int(mobj.group(1)),
90 'episode_number': int(mobj.group(2)),
91 'episode': mobj.group(3),