]>
Commit | Line | Data |
---|---|---|
12a129ec S |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
85b0fe7d | 3 | dict_get, |
12a129ec | 4 | float_or_none, |
12a129ec S |
5 | ) |
6 | ||
7 | ||
8 | class PlaywireIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:config|cdn)\.playwire\.com(?:/v2)?/(?P<publisher_id>\d+)/(?:videos/v2|embed|config)/(?P<id>\d+)' | |
bfd973ec | 10 | _EMBED_REGEX = [r'<script[^>]+data-config=(["\'])(?P<url>(?:https?:)?//config\.playwire\.com/.+?)\1'] |
11 | ||
12a129ec S |
12 | _TESTS = [{ |
13 | 'url': 'http://config.playwire.com/14907/videos/v2/3353705/player.json', | |
14 | 'md5': 'e6398701e3595888125729eaa2329ed9', | |
15 | 'info_dict': { | |
16 | 'id': '3353705', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'S04_RM_UCL_Rus', | |
ec85ded8 | 19 | 'thumbnail': r're:^https?://.*\.png$', |
12a129ec S |
20 | 'duration': 145.94, |
21 | }, | |
761052db YCH |
22 | }, { |
23 | # m3u8 in f4m | |
24 | 'url': 'http://config.playwire.com/21772/videos/v2/4840492/zeus.json', | |
25 | 'info_dict': { | |
26 | 'id': '4840492', | |
27 | 'ext': 'mp4', | |
28 | 'title': 'ITV EL SHOW FULL', | |
29 | }, | |
30 | 'params': { | |
31 | # m3u8 download | |
32 | 'skip_download': True, | |
33 | }, | |
12a129ec | 34 | }, { |
85b0fe7d | 35 | # Multiple resolutions while bitrates missing |
12a129ec S |
36 | 'url': 'http://cdn.playwire.com/11625/embed/85228.html', |
37 | 'only_matching': True, | |
38 | }, { | |
39 | 'url': 'http://config.playwire.com/12421/videos/v2/3389892/zeus.json', | |
40 | 'only_matching': True, | |
41 | }, { | |
42 | 'url': 'http://cdn.playwire.com/v2/12342/config/1532636.json', | |
43 | 'only_matching': True, | |
44 | }] | |
45 | ||
46 | def _real_extract(self, url): | |
5ad28e7f | 47 | mobj = self._match_valid_url(url) |
12a129ec S |
48 | publisher_id, video_id = mobj.group('publisher_id'), mobj.group('id') |
49 | ||
50 | player = self._download_json( | |
51 | 'http://config.playwire.com/%s/videos/v2/%s/zeus.json' % (publisher_id, video_id), | |
52 | video_id) | |
53 | ||
54 | title = player['settings']['title'] | |
55 | duration = float_or_none(player.get('duration'), 1000) | |
56 | ||
57 | content = player['content'] | |
58 | thumbnail = content.get('poster') | |
59 | src = content['media']['f4m'] | |
60 | ||
448bb5f3 | 61 | formats = self._extract_f4m_formats(src, video_id, m3u8_id='hls') |
85b0fe7d YCH |
62 | for a_format in formats: |
63 | if not dict_get(a_format, ['tbr', 'width', 'height']): | |
64 | a_format['quality'] = 1 if '-hd.' in a_format['url'] else 0 | |
12a129ec S |
65 | |
66 | return { | |
67 | 'id': video_id, | |
68 | 'title': title, | |
69 | 'thumbnail': thumbnail, | |
70 | 'duration': duration, | |
71 | 'formats': formats, | |
72 | } |