]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sevenplus.py
Update changelog
[youtubedl] / youtube_dl / extractor / sevenplus.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .brightcove import BrightcoveNewIE
7 from ..utils import update_url_query
8
9
10 class SevenPlusIE(BrightcoveNewIE):
11 IE_NAME = '7plus'
12 _VALID_URL = r'https?://(?:www\.)?7plus\.com\.au/(?P<path>[^?]+\?.*?\bepisode-id=(?P<id>[^&#]+))'
13 _TESTS = [{
14 'url': 'https://7plus.com.au/BEAT?episode-id=BEAT-001',
15 'info_dict': {
16 'id': 'BEAT-001',
17 'ext': 'mp4',
18 'title': 'S1 E1 - Help / Lucy In The Sky With Diamonds',
19 'description': 'md5:37718bea20a8eedaca7f7361af566131',
20 'uploader_id': '5303576322001',
21 'upload_date': '20171031',
22 'timestamp': 1509440068,
23 },
24 'params': {
25 'format': 'bestvideo',
26 'skip_download': True,
27 }
28 }, {
29 'url': 'https://7plus.com.au/UUUU?episode-id=AUMS43-001',
30 'only_matching': True,
31 }]
32
33 def _real_extract(self, url):
34 path, episode_id = re.match(self._VALID_URL, url).groups()
35
36 media = self._download_json(
37 'https://videoservice.swm.digital/playback', episode_id, query={
38 'appId': '7plus',
39 'deviceType': 'web',
40 'platformType': 'web',
41 'accountId': 5303576322001,
42 'referenceId': 'ref:' + episode_id,
43 'deliveryId': 'csai',
44 'videoType': 'vod',
45 })['media']
46
47 for source in media.get('sources', {}):
48 src = source.get('src')
49 if not src:
50 continue
51 source['src'] = update_url_query(src, {'rule': ''})
52
53 info = self._parse_brightcove_metadata(media, episode_id)
54
55 content = self._download_json(
56 'https://component-cdn.swm.digital/content/' + path,
57 episode_id, headers={
58 'market-id': 4,
59 }, fatal=False) or {}
60 for item in content.get('items', {}):
61 if item.get('componentData', {}).get('componentType') == 'infoPanel':
62 for src_key, dst_key in [('title', 'title'), ('shortSynopsis', 'description')]:
63 value = item.get(src_key)
64 if value:
65 info[dst_key] = value
66
67 return info