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.

37 lines
1.1 KiB

  1. from __future__ import unicode_literals
  2. import base64
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import compat_parse_qs
  6. class TutvIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
  8. _TEST = {
  9. 'url': 'http://tu.tv/videos/robots-futbolistas',
  10. 'md5': '627c7c124ac2a9b5ab6addb94e0e65f7',
  11. 'info_dict': {
  12. 'id': '2973058',
  13. 'ext': 'flv',
  14. 'title': 'Robots futbolistas',
  15. },
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  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 = base64.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. }