mitele.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. from .telecinco import TelecincoIE
  2. from ..utils import (
  3. int_or_none,
  4. parse_iso8601,
  5. )
  6. class MiTeleIE(TelecincoIE): # XXX: Do not subclass from concrete IE
  7. IE_DESC = 'mitele.es'
  8. _VALID_URL = r'https?://(?:www\.)?mitele\.es/(?:[^/]+/)+(?P<id>[^/]+)/player'
  9. _TESTS = [{
  10. 'url': 'http://www.mitele.es/programas-tv/diario-de/57b0dfb9c715da65618b4afa/player',
  11. 'info_dict': {
  12. 'id': 'FhYW1iNTE6J6H7NkQRIEzfne6t2quqPg',
  13. 'ext': 'mp4',
  14. 'title': 'Diario de La redacción Programa 144',
  15. 'description': 'md5:07c35a7b11abb05876a6a79185b58d27',
  16. 'series': 'Diario de',
  17. 'season': 'Season 14',
  18. 'season_number': 14,
  19. 'episode': 'Tor, la web invisible',
  20. 'episode_number': 3,
  21. 'thumbnail': r're:(?i)^https?://.*\.jpg$',
  22. 'duration': 2913,
  23. 'age_limit': 16,
  24. 'timestamp': 1471209401,
  25. 'upload_date': '20160814',
  26. },
  27. }, {
  28. # no explicit title
  29. 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player',
  30. 'info_dict': {
  31. 'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq',
  32. 'ext': 'mp4',
  33. 'title': 'Cuarto Milenio Temporada 6 Programa 226',
  34. 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
  35. 'series': 'Cuarto Milenio',
  36. 'season': 'Season 6',
  37. 'season_number': 6,
  38. 'episode': 'Episode 24',
  39. 'episode_number': 24,
  40. 'thumbnail': r're:(?i)^https?://.*\.jpg$',
  41. 'duration': 7313,
  42. 'age_limit': 12,
  43. 'timestamp': 1471209021,
  44. 'upload_date': '20160814',
  45. },
  46. 'params': {
  47. 'skip_download': True,
  48. },
  49. }, {
  50. 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
  51. 'only_matching': True,
  52. }, {
  53. 'url': 'https://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144-40_1006364575251/player/',
  54. 'only_matching': True,
  55. }]
  56. def _real_extract(self, url):
  57. display_id = self._match_id(url)
  58. webpage = self._download_webpage(url, display_id)
  59. pre_player = self._parse_json(self._search_regex(
  60. r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=\s*({.+})',
  61. webpage, 'Pre Player'), display_id)['prePlayer']
  62. title = pre_player['title']
  63. video_info = self._parse_content(pre_player['video'], url)
  64. content = pre_player.get('content') or {}
  65. info = content.get('info') or {}
  66. video_info.update({
  67. 'title': title,
  68. 'description': info.get('synopsis'),
  69. 'series': content.get('title'),
  70. 'season_number': int_or_none(info.get('season_number')),
  71. 'episode': content.get('subtitle'),
  72. 'episode_number': int_or_none(info.get('episode_number')),
  73. 'duration': int_or_none(info.get('duration')),
  74. 'age_limit': int_or_none(info.get('rating')),
  75. 'timestamp': parse_iso8601(pre_player.get('publishedTime')),
  76. })
  77. return video_info