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