2 from __future__ import unicode_literals
6 from .common import InfoExtractor
9 compat_urllib_parse_unquote,
13 get_element_by_attribute,
19 class TelecincoIE(InfoExtractor):
20 IE_NAME = 'telecinco.es'
21 _VALID_URL = r'https?://www\.telecinco\.es/(?:[^/]+/)+(?P<id>.+?)\.html'
24 'url': 'http://www.telecinco.es/robinfood/temporada-01/t01xp14/Bacalao-cocochas-pil-pil_0_1876350223.html',
26 'id': 'MDSVID20141015_0058',
28 'title': 'Con MartÃn Berasategui, hacer un bacalao al ...',
33 'skip_download': True,
36 'url': 'http://www.telecinco.es/informativos/nacional/Pablo_Iglesias-Informativos_Telecinco-entrevista-Pedro_Piqueras_2_1945155182.html',
37 'only_matching': True,
39 'url': 'http://www.telecinco.es/espanasinirmaslejos/Espana-gran-destino-turistico_2_1240605043.html',
40 'only_matching': True,
43 def _real_extract(self, url):
44 episode = self._match_id(url)
45 webpage = self._download_webpage(url, episode)
46 embed_data_json = self._search_regex(
47 r'(?s)MSV\.embedData\[.*?\]\s*=\s*({.*?});', webpage, 'embed data',
49 embed_data = json.loads(embed_data_json)
51 domain = embed_data['mediaUrl']
52 if not domain.startswith('http'):
53 # only happens in telecinco.es videos
54 domain = 'http://' + domain
55 info_url = compat_urlparse.urljoin(
57 compat_urllib_parse_unquote(embed_data['flashvars']['host'])
59 info_el = self._download_xml(info_url, episode).find('./video/info')
61 video_link = info_el.find('videoUrl/link').text
62 token_query = compat_urllib_parse.urlencode({'id': video_link})
63 token_info = self._download_json(
64 embed_data['flashvars']['ov_tk'] + '?' + token_query,
66 transform_source=strip_jsonp
68 formats = self._extract_m3u8_formats(
69 token_info['tokenizedUrl'], episode, ext='mp4')
72 'id': embed_data['videoId'],
73 'display_id': episode,
74 'title': info_el.find('title').text,
76 'description': get_element_by_attribute('class', 'text', webpage),
77 'thumbnail': info_el.find('thumb').text,
78 'duration': parse_duration(info_el.find('duration').text),