]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | float_or_none, | |
4 | int_or_none, | |
5 | parse_iso8601, | |
6 | sanitized_Request, | |
7 | ) | |
8 | ||
9 | ||
10 | class EitbIE(InfoExtractor): | |
11 | IE_NAME = 'eitb.tv' | |
12 | _VALID_URL = r'https?://(?:www\.)?eitb\.tv/(?:eu/bideoa|es/video)/[^/]+/\d+/(?P<id>\d+)' | |
13 | ||
14 | _TEST = { | |
15 | 'url': 'http://www.eitb.tv/es/video/60-minutos-60-minutos-2013-2014/4104995148001/4090227752001/lasa-y-zabala-30-anos/', | |
16 | 'md5': 'edf4436247185adee3ea18ce64c47998', | |
17 | 'info_dict': { | |
18 | 'id': '4090227752001', | |
19 | 'ext': 'mp4', | |
20 | 'title': '60 minutos (Lasa y Zabala, 30 aƱos)', | |
21 | 'description': 'Programa de reportajes de actualidad.', | |
22 | 'duration': 3996.76, | |
23 | 'timestamp': 1381789200, | |
24 | 'upload_date': '20131014', | |
25 | 'tags': list, | |
26 | }, | |
27 | } | |
28 | ||
29 | def _real_extract(self, url): | |
30 | video_id = self._match_id(url) | |
31 | ||
32 | video = self._download_json( | |
33 | 'http://mam.eitb.eus/mam/REST/ServiceMultiweb/Video/MULTIWEBTV/%s/' % video_id, | |
34 | video_id, 'Downloading video JSON') | |
35 | ||
36 | media = video['web_media'][0] | |
37 | ||
38 | formats = [] | |
39 | for rendition in media['RENDITIONS']: | |
40 | video_url = rendition.get('PMD_URL') | |
41 | if not video_url: | |
42 | continue | |
43 | tbr = float_or_none(rendition.get('ENCODING_RATE'), 1000) | |
44 | format_id = 'http' | |
45 | if tbr: | |
46 | format_id += '-%d' % int(tbr) | |
47 | formats.append({ | |
48 | 'url': rendition['PMD_URL'], | |
49 | 'format_id': format_id, | |
50 | 'width': int_or_none(rendition.get('FRAME_WIDTH')), | |
51 | 'height': int_or_none(rendition.get('FRAME_HEIGHT')), | |
52 | 'tbr': tbr, | |
53 | }) | |
54 | ||
55 | hls_url = media.get('HLS_SURL') | |
56 | if hls_url: | |
57 | request = sanitized_Request( | |
58 | 'http://mam.eitb.eus/mam/REST/ServiceMultiweb/DomainRestrictedSecurity/TokenAuth/', | |
59 | headers={'Referer': url}) | |
60 | token_data = self._download_json( | |
61 | request, video_id, 'Downloading auth token', fatal=False) | |
62 | if token_data: | |
63 | token = token_data.get('token') | |
64 | if token: | |
65 | formats.extend(self._extract_m3u8_formats( | |
66 | '%s?hdnts=%s' % (hls_url, token), video_id, m3u8_id='hls', fatal=False)) | |
67 | ||
68 | hds_url = media.get('HDS_SURL') | |
69 | if hds_url: | |
70 | formats.extend(self._extract_f4m_formats( | |
71 | '%s?hdcore=3.7.0' % hds_url.replace('euskalsvod', 'euskalvod'), | |
72 | video_id, f4m_id='hds', fatal=False)) | |
73 | ||
74 | self._sort_formats(formats) | |
75 | ||
76 | return { | |
77 | 'id': video_id, | |
78 | 'title': media.get('NAME_ES') or media.get('name') or media['NAME_EU'], | |
79 | 'description': media.get('SHORT_DESC_ES') or video.get('desc_group') or media.get('SHORT_DESC_EU'), | |
80 | 'thumbnail': media.get('STILL_URL') or media.get('THUMBNAIL_URL'), | |
81 | 'duration': float_or_none(media.get('LENGTH'), 1000), | |
82 | 'timestamp': parse_iso8601(media.get('BROADCST_DATE'), ' '), | |
83 | 'tags': media.get('TAGS'), | |
84 | 'formats': formats, | |
85 | } |