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