[cleanup] Misc (#8968)
[yt-dlp.git] / yt_dlp / extractor / mitele.py
blobea29986729caf36cd9f8eda6da1174cb8499a0ad
1 from .telecinco import TelecincoIE
2 from ..utils import (
3 int_or_none,
4 parse_iso8601,
8 class MiTeleIE(TelecincoIE): # XXX: Do not subclass from concrete IE
9 IE_DESC = 'mitele.es'
10 _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': 'Diario de La redacción Programa 144',
18 'description': 'md5:07c35a7b11abb05876a6a79185b58d27',
19 'series': 'Diario de',
20 'season': 'Season 14',
21 'season_number': 14,
22 'episode': 'Tor, la web invisible',
23 'episode_number': 3,
24 'thumbnail': r're:(?i)^https?://.*\.jpg$',
25 'duration': 2913,
26 'age_limit': 16,
27 'timestamp': 1471209401,
28 'upload_date': '20160814',
30 }, {
31 # no explicit title
32 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player',
33 'info_dict': {
34 'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq',
35 'ext': 'mp4',
36 'title': 'Cuarto Milenio Temporada 6 Programa 226',
37 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
38 'series': 'Cuarto Milenio',
39 'season': 'Season 6',
40 'season_number': 6,
41 'episode': 'Episode 24',
42 'episode_number': 24,
43 'thumbnail': r're:(?i)^https?://.*\.jpg$',
44 'duration': 7313,
45 'age_limit': 12,
46 'timestamp': 1471209021,
47 'upload_date': '20160814',
49 'params': {
50 'skip_download': True,
52 }, {
53 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
54 'only_matching': True,
55 }, {
56 'url': 'https://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144-40_1006364575251/player/',
57 'only_matching': True,
60 def _real_extract(self, url):
61 display_id = self._match_id(url)
62 webpage = self._download_webpage(url, display_id)
63 pre_player = self._parse_json(self._search_regex(
64 r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=\s*({.+})',
65 webpage, 'Pre Player'), display_id)['prePlayer']
66 title = pre_player['title']
67 video_info = self._parse_content(pre_player['video'], url)
68 content = pre_player.get('content') or {}
69 info = content.get('info') or {}
71 video_info.update({
72 'title': title,
73 'description': info.get('synopsis'),
74 'series': content.get('title'),
75 'season_number': int_or_none(info.get('season_number')),
76 'episode': content.get('subtitle'),
77 'episode_number': int_or_none(info.get('episode_number')),
78 'duration': int_or_none(info.get('duration')),
79 'age_limit': int_or_none(info.get('rating')),
80 'timestamp': parse_iso8601(pre_player.get('publishedTime')),
82 return video_info