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.

38 lines
1.2 KiB

  1. from __future__ import unicode_literals
  2. import base64
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_parse_qs,
  7. )
  8. class TutvIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
  10. _TEST = {
  11. 'url': 'http://tu.tv/videos/noah-en-pabellon-cuahutemoc',
  12. 'file': '2742556.flv',
  13. 'md5': '5eb766671f69b82e528dc1e7769c5cb2',
  14. 'info_dict': {
  15. 'title': 'Noah en pabellon cuahutemoc',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. webpage = self._download_webpage(url, video_id)
  22. internal_id = self._search_regex(r'codVideo=([0-9]+)', webpage, 'internal video ID')
  23. data_url = 'http://tu.tv/flvurl.php?codVideo=' + str(internal_id)
  24. data_content = self._download_webpage(data_url, video_id, note='Downloading video info')
  25. data = compat_parse_qs(data_content)
  26. video_url = base64.b64decode(data['kpt'][0]).decode('utf-8')
  27. return {
  28. 'id': internal_id,
  29. 'url': video_url,
  30. 'title': self._og_search_title(webpage),
  31. }