1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-24 11:11:54 +00:00
youtube-dl/youtube_dl/extractor/tutv.py

37 lines
1.1 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
2014-07-15 12:32:42 +00:00
2013-06-29 15:29:40 +00:00
from .common import InfoExtractor
from ..compat import (
compat_b64decode,
compat_parse_qs,
)
2013-06-29 15:29:40 +00:00
2013-06-29 15:29:40 +00:00
class TutvIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
2013-06-29 15:29:40 +00:00
_TEST = {
2014-07-15 12:32:42 +00:00
'url': 'http://tu.tv/videos/robots-futbolistas',
2015-10-24 12:22:47 +00:00
'md5': '0cd9e28ad270488911b0d2a72323395d',
'info_dict': {
2014-07-15 12:32:42 +00:00
'id': '2973058',
2015-10-24 12:22:47 +00:00
'ext': 'mp4',
2014-07-15 12:32:42 +00:00
'title': 'Robots futbolistas',
},
2013-06-29 15:29:40 +00:00
}
def _real_extract(self, url):
video_id = self._match_id(url)
2013-06-29 15:29:40 +00:00
webpage = self._download_webpage(url, video_id)
internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
2013-06-29 15:29:40 +00:00
2014-07-15 12:32:42 +00:00
data_content = self._download_webpage(
'http://tu.tv/flvurl.php?codVideo=%s' % internal_id, video_id, 'Downloading video info')
video_url = compat_b64decode(compat_parse_qs(data_content)['kpt'][0]).decode('utf-8')
2013-06-29 15:29:40 +00:00
return {
2013-06-29 15:29:40 +00:00
'id': internal_id,
'url': video_url,
'title': self._og_search_title(webpage),
2013-06-29 15:29:40 +00:00
}