]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mitele.py
40f214a873a7dcbb5087726aa270b74a5dab3e76
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  12 class MiTeleIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://(?:www\.)?mitele\.es/(?:[^/]+/)+(?P<id>[^/]+)/player' 
  17         'url': 'http://www.mitele.es/programas-tv/diario-de/57b0dfb9c715da65618b4afa/player', 
  19             'id': 'FhYW1iNTE6J6H7NkQRIEzfne6t2quqPg', 
  21             'title': 'Tor, la web invisible', 
  22             'description': 'md5:3b6fce7eaa41b2d97358726378d9369f', 
  23             'series': 'Diario de', 
  24             'season': 'La redacción', 
  26             'season_id': 'diario_de_t14_11981', 
  27             'episode': 'Programa 144', 
  29             'thumbnail': r
're:(?i)^https?://.*\.jpg$', 
  35         'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player', 
  37             'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq', 
  39             'title': 'Cuarto Milenio Temporada 6 Programa 226', 
  40             'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f', 
  41             'series': 'Cuarto Milenio', 
  42             'season': 'Temporada 6', 
  44             'season_id': 'cuarto_milenio_t06_12715', 
  45             'episode': 'Programa 226', 
  47             'thumbnail': r
're:(?i)^https?://.*\.jpg$', 
  51             'skip_download': True, 
  55         'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player', 
  56         'only_matching': True, 
  59     def _real_extract(self
, url
): 
  60         video_id 
= self
._match
_id
(url
) 
  62         paths 
= self
._download
_json
( 
  63             'https://www.mitele.es/amd/agp/web/metadata/general_configuration', 
  64             video_id
, 'Downloading paths JSON') 
  66         ooyala_s 
= paths
['general_configuration']['api_configuration']['ooyala_search'] 
  67         base_url 
= ooyala_s
.get('base_url', 'cdn-search-mediaset.carbyne.ps.ooyala.com') 
  68         full_path 
= ooyala_s
.get('full_path', '/search/v1/full/providers/') 
  69         source 
= self
._download
_json
( 
  70             '%s://%s%s%s/docs/%s' % ( 
  71                 ooyala_s
.get('protocol', 'https'), base_url
, full_path
, 
  72                 ooyala_s
.get('provider_id', '104951'), video_id
), 
  73             video_id
, 'Downloading data JSON', query
={ 
  74                 'include_titles': 'Series,Season', 
  75                 'product_name': ooyala_s
.get('product_name', 'test'), 
  77             })['hits']['hits'][0]['_source'] 
  79         embedCode 
= source
['offers'][0]['embed_codes'][0] 
  80         titles 
= source
['localizable_titles'][0] 
  82         title 
= titles
.get('title_medium') or titles
['title_long'] 
  84         description 
= titles
.get('summary_long') or titles
.get('summary_medium') 
  87             value1 
= source
.get(key1
) 
  88             if not value1 
or not isinstance(value1
, list): 
  90             if not isinstance(value1
[0], dict): 
  92             return value1
[0].get(key2
) 
  94         series 
= get('localizable_titles_series', 'title_medium') 
  96         season 
= get('localizable_titles_season', 'title_medium') 
  97         season_number 
= int_or_none(source
.get('season_number')) 
  98         season_id 
= source
.get('season_id') 
 100         episode 
= titles
.get('title_sort_name') 
 101         episode_number 
= int_or_none(source
.get('episode_number')) 
 103         duration 
= parse_duration(get('videos', 'duration')) 
 106             '_type': 'url_transparent', 
 107             # for some reason only HLS is supported 
 108             'url': smuggle_url('ooyala:' + embedCode
, {'supportedformats': 'm3u8,dash'}), 
 111             'description': description
, 
 114             'season_number': season_number
, 
 115             'season_id': season_id
, 
 117             'episode_number': episode_number
, 
 118             'duration': duration
, 
 119             'thumbnail': get('images', 'url'),