]> jfr.im git - yt-dlp.git/blame - youtube_dlc/extractor/mitele.py
Preparing for release
[yt-dlp.git] / youtube_dlc / extractor / mitele.py
CommitLineData
69295694 1# coding: utf-8
938dd254
JMF
2from __future__ import unicode_literals
3
29f7c58a 4from .telecinco import TelecincoIE
1cc79574 5from ..utils import (
f84ce1eb 6 int_or_none,
18ff573e 7 parse_iso8601,
938dd254
JMF
8)
9
10
29f7c58a 11class MiTeleIE(TelecincoIE):
3368d70d 12 IE_DESC = 'mitele.es'
b68599ed 13 _VALID_URL = r'https?://(?:www\.)?mitele\.es/(?:[^/]+/)+(?P<id>[^/]+)/player'
938dd254 14
69295694 15 _TESTS = [{
cb882540 16 'url': 'http://www.mitele.es/programas-tv/diario-de/57b0dfb9c715da65618b4afa/player',
938dd254 17 'info_dict': {
8e37a7e4 18 'id': 'FhYW1iNTE6J6H7NkQRIEzfne6t2quqPg',
47335a0e 19 'ext': 'mp4',
18ff573e
RA
20 'title': 'Diario de La redacción Programa 144',
21 'description': 'md5:07c35a7b11abb05876a6a79185b58d27',
69295694 22 'series': 'Diario de',
18ff573e 23 'season': 'Season 14',
8eb7b5c3 24 'season_number': 14,
18ff573e 25 'episode': 'Tor, la web invisible',
8eb7b5c3 26 'episode_number': 3,
ec85ded8 27 'thumbnail': r're:(?i)^https?://.*\.jpg$',
938dd254 28 'duration': 2913,
18ff573e
RA
29 'age_limit': 16,
30 'timestamp': 1471209401,
31 'upload_date': '20160814',
938dd254 32 },
69295694
S
33 }, {
34 # no explicit title
cb882540 35 'url': 'http://www.mitele.es/programas-tv/cuarto-milenio/57b0de3dc915da14058b4876/player',
69295694 36 'info_dict': {
8e37a7e4 37 'id': 'oyNG1iNTE6TAPP-JmCjbwfwJqqMMX3Vq',
47335a0e 38 'ext': 'mp4',
cb882540
D
39 'title': 'Cuarto Milenio Temporada 6 Programa 226',
40 'description': 'md5:5ff132013f0cd968ffbf1f5f3538a65f',
69295694 41 'series': 'Cuarto Milenio',
18ff573e 42 'season': 'Season 6',
8eb7b5c3 43 'season_number': 6,
18ff573e 44 'episode': 'Episode 24',
8eb7b5c3 45 'episode_number': 24,
ec85ded8 46 'thumbnail': r're:(?i)^https?://.*\.jpg$',
cb882540 47 'duration': 7313,
18ff573e
RA
48 'age_limit': 12,
49 'timestamp': 1471209021,
50 'upload_date': '20160814',
69295694
S
51 },
52 'params': {
53 'skip_download': True,
29f7c58a 54 },
b68599ed 55 }, {
56 'url': 'http://www.mitele.es/series-online/la-que-se-avecina/57aac5c1c915da951a8b45ed/player',
57 'only_matching': True,
18ff573e
RA
58 }, {
59 'url': 'https://www.mitele.es/programas-tv/diario-de/la-redaccion/programa-144-40_1006364575251/player/',
60 'only_matching': True,
69295694 61 }]
938dd254
JMF
62
63 def _real_extract(self, url):
18ff573e
RA
64 display_id = self._match_id(url)
65 webpage = self._download_webpage(url, display_id)
66 pre_player = self._parse_json(self._search_regex(
67 r'window\.\$REACTBASE_STATE\.prePlayer_mtweb\s*=\s*({.+})',
68 webpage, 'Pre Player'), display_id)['prePlayer']
69 title = pre_player['title']
29f7c58a 70 video_info = self._parse_content(pre_player['video'], url)
18ff573e
RA
71 content = pre_player.get('content') or {}
72 info = content.get('info') or {}
f84ce1eb 73
29f7c58a 74 video_info.update({
f84ce1eb 75 'title': title,
18ff573e
RA
76 'description': info.get('synopsis'),
77 'series': content.get('title'),
78 'season_number': int_or_none(info.get('season_number')),
79 'episode': content.get('subtitle'),
80 'episode_number': int_or_none(info.get('episode_number')),
81 'duration': int_or_none(info.get('duration')),
18ff573e
RA
82 'age_limit': int_or_none(info.get('rating')),
83 'timestamp': parse_iso8601(pre_player.get('publishedTime')),
29f7c58a 84 })
85 return video_info