You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB

9 years ago
9 years ago
  1. from __future__ import unicode_literals
  2. import base64
  3. from .common import InfoExtractor
  4. from ..compat import compat_parse_qs
  5. class TutvIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
  7. _TEST = {
  8. 'url': 'http://tu.tv/videos/robots-futbolistas',
  9. 'md5': '0cd9e28ad270488911b0d2a72323395d',
  10. 'info_dict': {
  11. 'id': '2973058',
  12. 'ext': 'mp4',
  13. 'title': 'Robots futbolistas',
  14. },
  15. }
  16. def _real_extract(self, url):
  17. video_id = self._match_id(url)
  18. webpage = self._download_webpage(url, video_id)
  19. internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
  20. data_content = self._download_webpage(
  21. 'http://tu.tv/flvurl.php?codVideo=%s' % internal_id, video_id, 'Downloading video info')
  22. video_url = base64.b64decode(compat_parse_qs(data_content)['kpt'][0].encode('utf-8')).decode('utf-8')
  23. return {
  24. 'id': internal_id,
  25. 'url': video_url,
  26. 'title': self._og_search_title(webpage),
  27. }