]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tutv.py
Fix lintian warning introduced by Ben's patch.
[youtubedl] / youtube_dl / extractor / tutv.py
1 from __future__ import unicode_literals
2
3 import base64
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import compat_parse_qs
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': '627c7c124ac2a9b5ab6addb94e0e65f7',
15 'info_dict': {
16 'id': '2973058',
17 'ext': 'flv',
18 'title': 'Robots futbolistas',
19 },
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 video_id = mobj.group('id')
25
26 webpage = self._download_webpage(url, video_id)
27 internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
28
29 data_content = self._download_webpage(
30 'http://tu.tv/flvurl.php?codVideo=%s' % internal_id, video_id, 'Downloading video info')
31 video_url = base64.b64decode(compat_parse_qs(data_content)['kpt'][0]).decode('utf-8')
32
33 return {
34 'id': internal_id,
35 'url': video_url,
36 'title': self._og_search_title(webpage),
37 }