]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tutv.py
Update changelog
[youtubedl] / youtube_dl / extractor / tutv.py
1 from __future__ import unicode_literals
2
3 import base64
4
5 from .common import InfoExtractor
6 from ..compat import compat_parse_qs
7
8
9 class TutvIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
11 _TEST = {
12 'url': 'http://tu.tv/videos/robots-futbolistas',
13 'md5': '0cd9e28ad270488911b0d2a72323395d',
14 'info_dict': {
15 'id': '2973058',
16 'ext': 'mp4',
17 'title': 'Robots futbolistas',
18 },
19 }
20
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
23 webpage = self._download_webpage(url, video_id)
24
25 internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
26
27 data_content = self._download_webpage(
28 'http://tu.tv/flvurl.php?codVideo=%s' % internal_id, video_id, 'Downloading video info')
29 video_url = base64.b64decode(compat_parse_qs(data_content)['kpt'][0].encode('utf-8')).decode('utf-8')
30
31 return {
32 'id': internal_id,
33 'url': video_url,
34 'title': self._og_search_title(webpage),
35 }