]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/tutv.py
Merge pull request #6533 from sceext2/fix-iqiyi-2015-08-10
[yt-dlp.git] / youtube_dl / extractor / tutv.py
CommitLineData
d4a21e0b 1from __future__ import unicode_literals
bd1f325b 2
9afb1afc 3import base64
9afb1afc
PH
4
5from .common import InfoExtractor
1cc79574 6from ..compat import compat_parse_qs
9afb1afc 7
d4a21e0b 8
9afb1afc 9class TutvIE(InfoExtractor):
d4a21e0b 10 _VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
9afb1afc 11 _TEST = {
bd1f325b
S
12 'url': 'http://tu.tv/videos/robots-futbolistas',
13 'md5': '627c7c124ac2a9b5ab6addb94e0e65f7',
d4a21e0b 14 'info_dict': {
bd1f325b
S
15 'id': '2973058',
16 'ext': 'flv',
17 'title': 'Robots futbolistas',
d4a21e0b 18 },
9afb1afc
PH
19 }
20
21 def _real_extract(self, url):
1cc79574 22 video_id = self._match_id(url)
9afb1afc 23 webpage = self._download_webpage(url, video_id)
1cc79574 24
d4a21e0b 25 internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
9afb1afc 26
bd1f325b
S
27 data_content = self._download_webpage(
28 'http://tu.tv/flvurl.php?codVideo=%s' % internal_id, video_id, 'Downloading video info')
0459432d 29 video_url = base64.b64decode(compat_parse_qs(data_content)['kpt'][0].encode('utf-8')).decode('utf-8')
9afb1afc 30
d4a21e0b 31 return {
9afb1afc
PH
32 'id': internal_id,
33 'url': video_url,
46720279 34 'title': self._og_search_title(webpage),
9afb1afc 35 }