logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

mitele.py (3220B)


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