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