]>
Commit | Line | Data |
---|---|---|
938dd254 JMF |
1 | from __future__ import unicode_literals |
2 | ||
938dd254 JMF |
3 | import json |
4 | ||
5 | from .common import InfoExtractor | |
1cc79574 | 6 | from ..compat import ( |
938dd254 | 7 | compat_urllib_parse, |
2c63ccec | 8 | compat_urlparse, |
1cc79574 PH |
9 | ) |
10 | from ..utils import ( | |
938dd254 JMF |
11 | get_element_by_attribute, |
12 | parse_duration, | |
13 | strip_jsonp, | |
14 | ) | |
15 | ||
16 | ||
17 | class MiTeleIE(InfoExtractor): | |
18 | IE_NAME = 'mitele.es' | |
1cc79574 | 19 | _VALID_URL = r'http://www\.mitele\.es/[^/]+/[^/]+/[^/]+/(?P<id>[^/]+)/' |
938dd254 | 20 | |
c10ea454 | 21 | _TESTS = [{ |
938dd254 | 22 | 'url': 'http://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144/', |
938dd254 JMF |
23 | 'info_dict': { |
24 | 'id': '0fce117d', | |
25 | 'ext': 'mp4', | |
26 | 'title': 'Programa 144 - Tor, la web invisible', | |
27 | 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f', | |
28 | 'display_id': 'programa-144', | |
29 | 'duration': 2913, | |
30 | }, | |
6ad9cb22 JMF |
31 | 'params': { |
32 | # m3u8 download | |
33 | 'skip_download': True, | |
34 | }, | |
c10ea454 | 35 | }] |
938dd254 JMF |
36 | |
37 | def _real_extract(self, url): | |
1cc79574 | 38 | episode = self._match_id(url) |
938dd254 JMF |
39 | webpage = self._download_webpage(url, episode) |
40 | embed_data_json = self._search_regex( | |
1cc79574 | 41 | r'(?s)MSV\.embedData\[.*?\]\s*=\s*({.*?});', webpage, 'embed data', |
938dd254 JMF |
42 | ).replace('\'', '"') |
43 | embed_data = json.loads(embed_data_json) | |
44 | ||
ad5f53ac JMF |
45 | domain = embed_data['mediaUrl'] |
46 | if not domain.startswith('http'): | |
47 | # only happens in telecinco.es videos | |
48 | domain = 'http://' + domain | |
2c63ccec | 49 | info_url = compat_urlparse.urljoin( |
ad5f53ac JMF |
50 | domain, |
51 | compat_urllib_parse.unquote(embed_data['flashvars']['host']) | |
52 | ) | |
938dd254 JMF |
53 | info_el = self._download_xml(info_url, episode).find('./video/info') |
54 | ||
55 | video_link = info_el.find('videoUrl/link').text | |
56 | token_query = compat_urllib_parse.urlencode({'id': video_link}) | |
57 | token_info = self._download_json( | |
ad5f53ac JMF |
58 | embed_data['flashvars']['ov_tk'] + '?' + token_query, |
59 | episode, | |
938dd254 JMF |
60 | transform_source=strip_jsonp |
61 | ) | |
6ad9cb22 JMF |
62 | formats = self._extract_m3u8_formats( |
63 | token_info['tokenizedUrl'], episode, ext='mp4') | |
938dd254 JMF |
64 | |
65 | return { | |
66 | 'id': embed_data['videoId'], | |
67 | 'display_id': episode, | |
68 | 'title': info_el.find('title').text, | |
6ad9cb22 | 69 | 'formats': formats, |
938dd254 JMF |
70 | 'description': get_element_by_attribute('class', 'text', webpage), |
71 | 'thumbnail': info_el.find('thumb').text, | |
72 | 'duration': parse_duration(info_el.find('duration').text), | |
73 | } |