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