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.

36 lines
1.1 KiB

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