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.

60 lines
2.0 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urllib_parse,
  7. get_element_by_attribute,
  8. parse_duration,
  9. strip_jsonp,
  10. )
  11. class MiTeleIE(InfoExtractor):
  12. IE_NAME = 'mitele.es'
  13. _VALID_URL = r'http://www\.mitele\.es/[^/]+/[^/]+/[^/]+/(?P<episode>[^/]+)/'
  14. _TEST = {
  15. 'url': 'http://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144/',
  16. 'md5': '6a75fe9d0d3275bead0cb683c616fddb',
  17. 'info_dict': {
  18. 'id': '0fce117d',
  19. 'ext': 'mp4',
  20. 'title': 'Programa 144 - Tor, la web invisible',
  21. 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f',
  22. 'display_id': 'programa-144',
  23. 'duration': 2913,
  24. },
  25. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. episode = mobj.group('episode')
  29. webpage = self._download_webpage(url, episode)
  30. embed_data_json = self._search_regex(
  31. r'MSV\.embedData\[.*?\]\s*=\s*({.*?});', webpage, 'embed data',
  32. flags=re.DOTALL
  33. ).replace('\'', '"')
  34. embed_data = json.loads(embed_data_json)
  35. info_url = embed_data['flashvars']['host']
  36. info_el = self._download_xml(info_url, episode).find('./video/info')
  37. video_link = info_el.find('videoUrl/link').text
  38. token_query = compat_urllib_parse.urlencode({'id': video_link})
  39. token_info = self._download_json(
  40. 'http://token.mitele.es/?' + token_query, episode,
  41. transform_source=strip_jsonp
  42. )
  43. return {
  44. 'id': embed_data['videoId'],
  45. 'display_id': episode,
  46. 'title': info_el.find('title').text,
  47. 'url': token_info['tokenizedUrl'],
  48. 'description': get_element_by_attribute('class', 'text', webpage),
  49. 'thumbnail': info_el.find('thumb').text,
  50. 'duration': parse_duration(info_el.find('duration').text),
  51. }