1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-11 07:26:06 +01:00
youtube-dl/youtube_dl/extractor/tutv.py

39 lines
1.2 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
2013-06-29 17:29:40 +02:00
import base64
import re
from .common import InfoExtractor
from ..utils import (
compat_parse_qs,
)
2013-06-29 17:29:40 +02:00
class TutvIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
2013-06-29 17:29:40 +02:00
_TEST = {
'url': 'http://tu.tv/videos/noah-en-pabellon-cuahutemoc',
'file': '2742556.flv',
'md5': '5eb766671f69b82e528dc1e7769c5cb2',
'info_dict': {
'title': 'Noah en pabellon cuahutemoc',
},
2013-06-29 17:29:40 +02: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)
internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
2013-06-29 17:29:40 +02: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-29 17:29:40 +02:00
data = compat_parse_qs(data_content)
2013-06-29 17:42:15 +02:00
video_url = base64.b64decode(data['kpt'][0]).decode('utf-8')
2013-06-29 17:29:40 +02:00
return {
2013-06-29 17:29:40 +02:00
'id': internal_id,
'url': video_url,
'title': self._og_search_title(webpage),
2013-06-29 17:29:40 +02:00
}