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.

120 lines
4.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. smuggle_url,
  7. parse_duration,
  8. )
  9. class MiTeleIE(InfoExtractor):
  10. IE_DESC = 'mitele.es'
  11. _VALID_URL = r'https?://(?:www\.)?mitele\.es/(?:[^/]+/)+(?P<id>[^/]+)/player'
  12. _TESTS = [{
  13. 'url': 'http://www.mitele.es/programas-tv/diario-de/57b0dfb9c715da65618b4afa/player',
  14. 'info_dict': {
  15. 'id': 'FhYW1iNTE6J6H7NkQRIEzfne6t2quqPg',
  16. 'ext': 'mp4',
  17. 'title': 'Tor, la web invisible',
  18. 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f',
  19. 'series': 'Diario de',
  20. 'season': 'La redacción',
  21. 'season_number': 14,
  22. 'season_id': 'diario_de_t14_11981',
  23. 'episode': 'Programa 144',
  24. 'episode_number': 3,
  25. 'thumbnail': r're:(?i)^https?://.*\.jpg$',
  26. 'duration': 2913,
  27. },
  28. 'add_ie': ['Ooyala'],
  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': 'Temporada 6',
  39. 'season_number': 6,
  40. 'season_id': 'cuarto_milenio_t06_12715',
  41. 'episode': 'Programa 226',
  42. 'episode_number': 24,
  43. 'thumbnail': r're:(?i)^https?://.*\.jpg$',
  44. 'duration': 7313,
  45. },
  46. 'params': {
  47. 'skip_download': True,
  48. },
  49. 'add_ie': ['Ooyala'],
  50. }, {
  51. 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
  52. 'only_matching': True,
  53. }]
  54. def _real_extract(self, url):
  55. video_id = self._match_id(url)
  56. paths = self._download_json(
  57. 'https://www.mitele.es/amd/agp/web/metadata/general_configuration',
  58. video_id, 'Downloading paths JSON')
  59. ooyala_s = paths['general_configuration']['api_configuration']['ooyala_search']
  60. base_url = ooyala_s.get('base_url', 'cdn-search-mediaset.carbyne.ps.ooyala.com')
  61. full_path = ooyala_s.get('full_path', '/search/v1/full/providers/')
  62. source = self._download_json(
  63. '%s://%s%s%s/docs/%s' % (
  64. ooyala_s.get('protocol', 'https'), base_url, full_path,
  65. ooyala_s.get('provider_id', '104951'), video_id),
  66. video_id, 'Downloading data JSON', query={
  67. 'include_titles': 'Series,Season',
  68. 'product_name': ooyala_s.get('product_name', 'test'),
  69. 'format': 'full',
  70. })['hits']['hits'][0]['_source']
  71. embedCode = source['offers'][0]['embed_codes'][0]
  72. titles = source['localizable_titles'][0]
  73. title = titles.get('title_medium') or titles['title_long']
  74. description = titles.get('summary_long') or titles.get('summary_medium')
  75. def get(key1, key2):
  76. value1 = source.get(key1)
  77. if not value1 or not isinstance(value1, list):
  78. return
  79. if not isinstance(value1[0], dict):
  80. return
  81. return value1[0].get(key2)
  82. series = get('localizable_titles_series', 'title_medium')
  83. season = get('localizable_titles_season', 'title_medium')
  84. season_number = int_or_none(source.get('season_number'))
  85. season_id = source.get('season_id')
  86. episode = titles.get('title_sort_name')
  87. episode_number = int_or_none(source.get('episode_number'))
  88. duration = parse_duration(get('videos', 'duration'))
  89. return {
  90. '_type': 'url_transparent',
  91. # for some reason only HLS is supported
  92. 'url': smuggle_url('ooyala:' + embedCode, {'supportedformats': 'm3u8,dash'}),
  93. 'id': video_id,
  94. 'title': title,
  95. 'description': description,
  96. 'series': series,
  97. 'season': season,
  98. 'season_number': season_number,
  99. 'season_id': season_id,
  100. 'episode': episode,
  101. 'episode_number': episode_number,
  102. 'duration': duration,
  103. 'thumbnail': get('images', 'url'),
  104. }