]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mitele.py
Update README.md
[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 parse_iso8601,
8 smuggle_url,
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': 'Diario de La redacción Programa 144',
22 'description': 'md5:07c35a7b11abb05876a6a79185b58d27',
23 'series': 'Diario de',
24 'season': 'Season 14',
25 'season_number': 14,
26 'episode': 'Tor, la web invisible',
27 'episode_number': 3,
28 'thumbnail': r're:(?i)^https?://.*\.jpg$',
29 'duration': 2913,
30 'age_limit': 16,
31 'timestamp': 1471209401,
32 'upload_date': '20160814',
33 },
34 'add_ie': ['Ooyala'],
35 }, {
36 # no explicit title
37 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player',
38 'info_dict': {
39 'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq',
40 'ext': 'mp4',
41 'title': 'Cuarto Milenio Temporada 6 Programa 226',
42 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
43 'series': 'Cuarto Milenio',
44 'season': 'Season 6',
45 'season_number': 6,
46 'episode': 'Episode 24',
47 'episode_number': 24,
48 'thumbnail': r're:(?i)^https?://.*\.jpg$',
49 'duration': 7313,
50 'age_limit': 12,
51 'timestamp': 1471209021,
52 'upload_date': '20160814',
53 },
54 'params': {
55 'skip_download': True,
56 },
57 'add_ie': ['Ooyala'],
58 }, {
59 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
60 'only_matching': True,
61 }, {
62 'url': 'https://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144-40_1006364575251/player/',
63 'only_matching': True,
64 }]
65
66 def _real_extract(self, url):
67 display_id = self._match_id(url)
68 webpage = self._download_webpage(url, display_id)
69 pre_player = self._parse_json(self._search_regex(
70 r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=\s*({.+})',
71 webpage, 'Pre Player'), display_id)['prePlayer']
72 title = pre_player['title']
73 video = pre_player['video']
74 video_id = video['dataMediaId']
75 content = pre_player.get('content') or {}
76 info = content.get('info') or {}
77
78 return {
79 '_type': 'url_transparent',
80 # for some reason only HLS is supported
81 'url': smuggle_url('ooyala:' + video_id, {'supportedformats': 'm3u8,dash'}),
82 'id': video_id,
83 'title': title,
84 'description': info.get('synopsis'),
85 'series': content.get('title'),
86 'season_number': int_or_none(info.get('season_number')),
87 'episode': content.get('subtitle'),
88 'episode_number': int_or_none(info.get('episode_number')),
89 'duration': int_or_none(info.get('duration')),
90 'thumbnail': video.get('dataPoster'),
91 'age_limit': int_or_none(info.get('rating')),
92 'timestamp': parse_iso8601(pre_player.get('publishedTime')),
93 }