2 from __future__ import unicode_literals
6 from .common import InfoExtractor
8 compat_urllib_parse_urlencode,
12 get_element_by_attribute,
18 class MiTeleIE(InfoExtractor):
20 _VALID_URL = r'https?://www\.mitele\.es/[^/]+/[^/]+/[^/]+/(?P<id>[^/]+)/'
23 'url': 'http://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144/',
26 'id': '0NF1jJnxS1Wu3pHrmvFyw2',
27 'display_id': 'programa-144',
29 'title': 'Tor, la web invisible',
30 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f',
31 'series': 'Diario de',
32 'season': 'La redacción',
33 'episode': 'Programa 144',
34 'thumbnail': 're:(?i)^https?://.*\.jpg$',
39 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/temporada-6/programa-226/',
41 'id': 'eLZSwoEd1S3pVyUm8lc6F',
42 'display_id': 'programa-226',
44 'title': 'Cuarto Milenio - Temporada 6 - Programa 226',
45 'description': 'md5:50daf9fadefa4e62d9fc866d0c015701',
46 'series': 'Cuarto Milenio',
47 'season': 'Temporada 6',
48 'episode': 'Programa 226',
49 'thumbnail': 're:(?i)^https?://.*\.jpg$',
53 'skip_download': True,
57 def _real_extract(self, url):
58 display_id = self._match_id(url)
60 webpage = self._download_webpage(url, display_id)
62 config_url = self._search_regex(
63 r'data-config\s*=\s*"([^"]+)"', webpage, 'data config url')
64 config_url = compat_urlparse.urljoin(url, config_url)
66 config = self._download_json(
67 config_url, display_id, 'Downloading config JSON')
69 mmc = self._download_json(
70 config['services']['mmc'], display_id, 'Downloading mmc JSON')
73 for location in mmc['locations']:
74 gat = self._proto_relative_url(location.get('gat'), 'http:')
75 bas = location.get('bas')
76 loc = location.get('loc')
77 ogn = location.get('ogn')
78 if None in (gat, bas, loc, ogn):
86 media = self._download_json(
87 '%s/?%s' % (gat, compat_urllib_parse_urlencode(token_data)),
88 display_id, 'Downloading %s JSON' % location['loc'])
89 file_ = media.get('file')
92 formats.extend(self._extract_f4m_formats(
93 file_ + '&hdcore=3.2.0&plugin=aasp-3.2.0.77.18',
94 display_id, f4m_id=loc))
95 self._sort_formats(formats)
97 title = self._search_regex(
98 r'class="Destacado-text"[^>]*>\s*<strong>([^<]+)</strong>',
99 webpage, 'title', default=None)
101 mobj = re.search(r'''(?sx)
102 class="Destacado-text"[^>]*>.*?<h1>\s*
103 <span>(?P<series>[^<]+)</span>\s*
104 <span>(?P<season>[^<]+)</span>\s*
105 <span>(?P<episode>[^<]+)</span>''', webpage)
106 series, season, episode = mobj.groups() if mobj else [None] * 3
110 title = '%s - %s - %s' % (series, season, episode)
112 title = remove_start(self._search_regex(
113 r'<title>([^<]+)</title>', webpage, 'title'), 'Ver online ')
115 video_id = self._search_regex(
116 r'data-media-id\s*=\s*"([^"]+)"', webpage,
117 'data media id', default=None) or display_id
118 thumbnail = config.get('poster', {}).get('imageUrl')
119 duration = int_or_none(mmc.get('duration'))
123 'display_id': display_id,
125 'description': get_element_by_attribute('class', 'text', webpage),
129 'thumbnail': thumbnail,
130 'duration': duration,