2014-01-29 23:21:12 +09:00
|
|
|
from __future__ import unicode_literals
|
2013-06-30 00:29:40 +09:00
|
|
|
import base64
|
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
compat_parse_qs,
|
|
|
|
)
|
|
|
|
|
2014-01-29 23:21:12 +09:00
|
|
|
|
2013-06-30 00:29:40 +09:00
|
|
|
class TutvIE(InfoExtractor):
|
2014-01-29 23:21:12 +09:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
|
2013-06-30 00:29:40 +09:00
|
|
|
_TEST = {
|
2014-01-29 23:21:12 +09:00
|
|
|
'url': 'http://tu.tv/videos/noah-en-pabellon-cuahutemoc',
|
|
|
|
'file': '2742556.flv',
|
|
|
|
'md5': '5eb766671f69b82e528dc1e7769c5cb2',
|
|
|
|
'info_dict': {
|
|
|
|
'title': 'Noah en pabellon cuahutemoc',
|
|
|
|
},
|
2013-06-30 00:29:40 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
mobj = re.match(self._VALID_URL, url)
|
|
|
|
video_id = mobj.group('id')
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
2014-01-29 23:21:12 +09:00
|
|
|
internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
|
2013-06-30 00:29:40 +09:00
|
|
|
|
2014-01-29 23:21:12 +09:00
|
|
|
data_url = 'http://tu.tv/flvurl.php?codVideo=' + str(internal_id)
|
|
|
|
data_content = self._download_webpage(data_url, video_id, note='Downloading video info')
|
2013-06-30 00:29:40 +09:00
|
|
|
data = compat_parse_qs(data_content)
|
2013-06-30 00:42:15 +09:00
|
|
|
video_url = base64.b64decode(data['kpt'][0]).decode('utf-8')
|
2013-06-30 00:29:40 +09:00
|
|
|
|
2014-01-29 23:21:12 +09:00
|
|
|
return {
|
2013-06-30 00:29:40 +09:00
|
|
|
'id': internal_id,
|
|
|
|
'url': video_url,
|
2013-07-13 02:00:19 +09:00
|
|
|
'title': self._og_search_title(webpage),
|
2013-06-30 00:29:40 +09:00
|
|
|
}
|