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.

39 lines
1.2 KiB

  1. import base64
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_parse_qs,
  6. )
  7. class TutvIE(InfoExtractor):
  8. _VALID_URL=r'https?://(?:www\.)?tu\.tv/videos/(?P<id>[^/?]+)'
  9. _TEST = {
  10. u'url': u'http://tu.tv/videos/noah-en-pabellon-cuahutemoc',
  11. u'file': u'2742556.flv',
  12. u'md5': u'5eb766671f69b82e528dc1e7769c5cb2',
  13. u'info_dict': {
  14. u"title": u"Noah en pabellon cuahutemoc"
  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, u'internal video ID')
  22. data_url = u'http://tu.tv/flvurl.php?codVideo=' + str(internal_id)
  23. data_content = self._download_webpage(data_url, video_id, note=u'Downloading video info')
  24. data = compat_parse_qs(data_content)
  25. video_url = base64.b64decode(data['kpt'][0]).decode('utf-8')
  26. ext = video_url.partition(u'?')[0].rpartition(u'.')[2]
  27. info = {
  28. 'id': internal_id,
  29. 'url': video_url,
  30. 'ext': ext,
  31. 'title': self._og_search_title(webpage),
  32. }
  33. return [info]