]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/mitele.py
pull changes from remote master (#190)
[yt-dlp.git] / youtube_dl / extractor / mitele.py
CommitLineData
69295694 1# coding: utf-8
938dd254
JMF
2from __future__ import unicode_literals
3
938dd254 4from .common import InfoExtractor
1cc79574 5from ..utils import (
f84ce1eb 6 int_or_none,
b827ee92 7 parse_iso8601,
cb882540 8 smuggle_url,
938dd254
JMF
9)
10
11
cb882540 12class MiTeleIE(InfoExtractor):
3368d70d 13 IE_DESC = 'mitele.es'
b68599ed 14 _VALID_URL = r'https?://(?:www\.)?mitele\.es/(?:[^/]+/)+(?P<id>[^/]+)/player'
938dd254 15
69295694 16 _TESTS = [{
cb882540 17 'url': 'http://www.mitele.es/programas-tv/diario-de/57b0dfb9c715da65618b4afa/player',
938dd254 18 'info_dict': {
8e37a7e4 19 'id': 'FhYW1iNTE6J6H7NkQRIEzfne6t2quqPg',
47335a0e 20 'ext': 'mp4',
b827ee92
AG
21 'title': 'Diario de La redacción Programa 144',
22 'description': 'md5:07c35a7b11abb05876a6a79185b58d27',
69295694 23 'series': 'Diario de',
b827ee92 24 'season': 'Season 14',
8eb7b5c3 25 'season_number': 14,
b827ee92 26 'episode': 'Tor, la web invisible',
8eb7b5c3 27 'episode_number': 3,
ec85ded8 28 'thumbnail': r're:(?i)^https?://.*\.jpg$',
938dd254 29 'duration': 2913,
b827ee92
AG
30 'age_limit': 16,
31 'timestamp': 1471209401,
32 'upload_date': '20160814',
938dd254 33 },
cb882540 34 'add_ie': ['Ooyala'],
69295694
S
35 }, {
36 # no explicit title
cb882540 37 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player',
69295694 38 'info_dict': {
8e37a7e4 39 'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq',
47335a0e 40 'ext': 'mp4',
cb882540
D
41 'title': 'Cuarto Milenio Temporada 6 Programa 226',
42 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
69295694 43 'series': 'Cuarto Milenio',
b827ee92 44 'season': 'Season 6',
8eb7b5c3 45 'season_number': 6,
b827ee92 46 'episode': 'Episode 24',
8eb7b5c3 47 'episode_number': 24,
ec85ded8 48 'thumbnail': r're:(?i)^https?://.*\.jpg$',
cb882540 49 'duration': 7313,
b827ee92
AG
50 'age_limit': 12,
51 'timestamp': 1471209021,
52 'upload_date': '20160814',
69295694
S
53 },
54 'params': {
55 'skip_download': True,
56 },
cb882540 57 'add_ie': ['Ooyala'],
b68599ed 58 }, {
59 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
60 'only_matching': True,
b827ee92
AG
61 }, {
62 'url': 'https://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144-40_1006364575251/player/',
63 'only_matching': True,
69295694 64 }]
938dd254
JMF
65
66 def _real_extract(self, url):
b827ee92
AG
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 {}
f84ce1eb 77
cb882540
D
78 return {
79 '_type': 'url_transparent',
80 # for some reason only HLS is supported
b827ee92 81 'url': smuggle_url('ooyala:' + video_id, {'supportedformats': 'm3u8,dash'}),
cb882540 82 'id': video_id,
f84ce1eb 83 'title': title,
b827ee92
AG
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')),
cb882540 93 }