]>
Commit | Line | Data |
---|---|---|
938dd254 JMF |
1 | from __future__ import unicode_literals |
2 | ||
938dd254 | 3 | from .common import InfoExtractor |
eb97f46e | 4 | from ..compat import ( |
15707c7e | 5 | compat_urllib_parse_urlencode, |
eb97f46e JMF |
6 | compat_urlparse, |
7 | ) | |
1cc79574 | 8 | from ..utils import ( |
938dd254 | 9 | get_element_by_attribute, |
f84ce1eb | 10 | int_or_none, |
938dd254 JMF |
11 | ) |
12 | ||
13 | ||
14 | class MiTeleIE(InfoExtractor): | |
3368d70d | 15 | IE_DESC = 'mitele.es' |
5886b38d | 16 | _VALID_URL = r'https?://www\.mitele\.es/[^/]+/[^/]+/[^/]+/(?P<id>[^/]+)/' |
938dd254 | 17 | |
c10ea454 | 18 | _TESTS = [{ |
938dd254 | 19 | 'url': 'http://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144/', |
eb97f46e | 20 | 'md5': '0ff1a13aebb35d9bc14081ff633dd324', |
938dd254 | 21 | 'info_dict': { |
f84ce1eb | 22 | 'id': '0NF1jJnxS1Wu3pHrmvFyw2', |
938dd254 | 23 | 'display_id': 'programa-144', |
f84ce1eb S |
24 | 'ext': 'flv', |
25 | 'title': 'Tor, la web invisible', | |
26 | 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f', | |
27 | 'thumbnail': 're:(?i)^https?://.*\.jpg$', | |
938dd254 JMF |
28 | 'duration': 2913, |
29 | }, | |
c10ea454 | 30 | }] |
938dd254 JMF |
31 | |
32 | def _real_extract(self, url): | |
f84ce1eb S |
33 | display_id = self._match_id(url) |
34 | ||
35 | webpage = self._download_webpage(url, display_id) | |
938dd254 | 36 | |
f84ce1eb S |
37 | config_url = self._search_regex( |
38 | r'data-config\s*=\s*"([^"]+)"', webpage, 'data config url') | |
eb97f46e | 39 | config_url = compat_urlparse.urljoin(url, config_url) |
938dd254 | 40 | |
f84ce1eb S |
41 | config = self._download_json( |
42 | config_url, display_id, 'Downloading config JSON') | |
43 | ||
44 | mmc = self._download_json( | |
45 | config['services']['mmc'], display_id, 'Downloading mmc JSON') | |
46 | ||
47 | formats = [] | |
48 | for location in mmc['locations']: | |
49 | gat = self._proto_relative_url(location.get('gat'), 'http:') | |
50 | bas = location.get('bas') | |
51 | loc = location.get('loc') | |
52 | ogn = location.get('ogn') | |
53 | if None in (gat, bas, loc, ogn): | |
54 | continue | |
55 | token_data = { | |
56 | 'bas': bas, | |
57 | 'icd': loc, | |
58 | 'ogn': ogn, | |
59 | 'sta': '0', | |
60 | } | |
61 | media = self._download_json( | |
15707c7e | 62 | '%s/?%s' % (gat, compat_urllib_parse_urlencode(token_data)), |
f84ce1eb S |
63 | display_id, 'Downloading %s JSON' % location['loc']) |
64 | file_ = media.get('file') | |
65 | if not file_: | |
66 | continue | |
67 | formats.extend(self._extract_f4m_formats( | |
68 | file_ + '&hdcore=3.2.0&plugin=aasp-3.2.0.77.18', | |
69 | display_id, f4m_id=loc)) | |
70 | ||
71 | title = self._search_regex( | |
72 | r'class="Destacado-text"[^>]*>\s*<strong>([^<]+)</strong>', webpage, 'title') | |
73 | ||
74 | video_id = self._search_regex( | |
75 | r'data-media-id\s*=\s*"([^"]+)"', webpage, | |
76 | 'data media id', default=None) or display_id | |
77 | thumbnail = config.get('poster', {}).get('imageUrl') | |
78 | duration = int_or_none(mmc.get('duration')) | |
938dd254 JMF |
79 | |
80 | return { | |
f84ce1eb S |
81 | 'id': video_id, |
82 | 'display_id': display_id, | |
83 | 'title': title, | |
938dd254 | 84 | 'description': get_element_by_attribute('class', 'text', webpage), |
f84ce1eb S |
85 | 'thumbnail': thumbnail, |
86 | 'duration': duration, | |
87 | 'formats': formats, | |
938dd254 | 88 | } |