]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mitele.py
debian/changelog: Annotate with bug being closed.
[youtubedl] / youtube_dl / extractor / mitele.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 int_or_none,
7 smuggle_url,
8 parse_duration,
9 )
10
11
12 class MiTeleIE(InfoExtractor):
13 IE_DESC = 'mitele.es'
14 _VALID_URL = r'https?://(?:www\.)?mitele\.es/(?:[^/]+/)+(?P<id>[^/]+)/player'
15
16 _TESTS = [{
17 'url': 'http://www.mitele.es/programas-tv/diario-de/57b0dfb9c715da65618b4afa/player',
18 'info_dict': {
19 'id': 'FhYW1iNTE6J6H7NkQRIEzfne6t2quqPg',
20 'ext': 'mp4',
21 'title': 'Tor, la web invisible',
22 'description': 'md5:3b6fce7eaa41b2d97358726378d9369f',
23 'series': 'Diario de',
24 'season': 'La redacción',
25 'season_number': 14,
26 'season_id': 'diario_de_t14_11981',
27 'episode': 'Programa 144',
28 'episode_number': 3,
29 'thumbnail': r're:(?i)^https?://.*\.jpg$',
30 'duration': 2913,
31 },
32 'add_ie': ['Ooyala'],
33 }, {
34 # no explicit title
35 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player',
36 'info_dict': {
37 'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq',
38 'ext': 'mp4',
39 'title': 'Cuarto Milenio Temporada 6 Programa 226',
40 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
41 'series': 'Cuarto Milenio',
42 'season': 'Temporada 6',
43 'season_number': 6,
44 'season_id': 'cuarto_milenio_t06_12715',
45 'episode': 'Programa 226',
46 'episode_number': 24,
47 'thumbnail': r're:(?i)^https?://.*\.jpg$',
48 'duration': 7313,
49 },
50 'params': {
51 'skip_download': True,
52 },
53 'add_ie': ['Ooyala'],
54 }, {
55 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
56 'only_matching': True,
57 }]
58
59 def _real_extract(self, url):
60 video_id = self._match_id(url)
61
62 paths = self._download_json(
63 'https://www.mitele.es/amd/agp/web/metadata/general_configuration',
64 video_id, 'Downloading paths JSON')
65
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'),
76 'format': 'full',
77 })['hits']['hits'][0]['_source']
78
79 embedCode = source['offers'][0]['embed_codes'][0]
80 titles = source['localizable_titles'][0]
81
82 title = titles.get('title_medium') or titles['title_long']
83
84 description = titles.get('summary_long') or titles.get('summary_medium')
85
86 def get(key1, key2):
87 value1 = source.get(key1)
88 if not value1 or not isinstance(value1, list):
89 return
90 if not isinstance(value1[0], dict):
91 return
92 return value1[0].get(key2)
93
94 series = get('localizable_titles_series', 'title_medium')
95
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')
99
100 episode = titles.get('title_sort_name')
101 episode_number = int_or_none(source.get('episode_number'))
102
103 duration = parse_duration(get('videos', 'duration'))
104
105 return {
106 '_type': 'url_transparent',
107 # for some reason only HLS is supported
108 'url': smuggle_url('ooyala:' + embedCode, {'supportedformats': 'm3u8,dash'}),
109 'id': video_id,
110 'title': title,
111 'description': description,
112 'series': series,
113 'season': season,
114 'season_number': season_number,
115 'season_id': season_id,
116 'episode': episode,
117 'episode_number': episode_number,
118 'duration': duration,
119 'thumbnail': get('images', 'url'),
120 }