1 from __future__ import unicode_literals
3 from .common import InfoExtractor
5 compat_urllib_parse_urlencode,
9 get_element_by_attribute,
14 class MiTeleIE(InfoExtractor):
16 _VALID_URL = r'https?://www\.mitele\.es/[^/]+/[^/]+/[^/]+/(?P<id>[^/]+)/'
19 'url': 'http://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144/',
22 'id': '0NF1jJnxS1Wu3pHrmvFyw2',
23 'display_id': 'programa-144',
25 'title': 'Tor, la web invisible',
26 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f',
27 'thumbnail': 're:(?i)^https?://.*\.jpg$',
32 def _real_extract(self, url):
33 display_id = self._match_id(url)
35 webpage = self._download_webpage(url, display_id)
37 config_url = self._search_regex(
38 r'data-config\s*=\s*"([^"]+)"', webpage, 'data config url')
39 config_url = compat_urlparse.urljoin(url, config_url)
41 config = self._download_json(
42 config_url, display_id, 'Downloading config JSON')
44 mmc = self._download_json(
45 config['services']['mmc'], display_id, 'Downloading mmc JSON')
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):
61 media = self._download_json(
62 '%s/?%s' % (gat, compat_urllib_parse_urlencode(token_data)),
63 display_id, 'Downloading %s JSON' % location['loc'])
64 file_ = media.get('file')
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 self._sort_formats(formats)
72 title = self._search_regex(
73 r'class="Destacado-text"[^>]*>\s*<strong>([^<]+)</strong>', webpage, 'title')
75 video_id = self._search_regex(
76 r'data-media-id\s*=\s*"([^"]+)"', webpage,
77 'data media id', default=None) or display_id
78 thumbnail = config.get('poster', {}).get('imageUrl')
79 duration = int_or_none(mmc.get('duration'))
83 'display_id': display_id,
85 'description': get_element_by_attribute('class', 'text', webpage),
86 'thumbnail': thumbnail,