[ie/dplay] Fix extractors (#10471)
[yt-dlp3.git] / yt_dlp / extractor / markiza.py
blob088b60d554043d69d1549e47389f4331457fcebe
1 import re
3 from .common import InfoExtractor
4 from ..utils import (
5 orderedSet,
6 parse_duration,
7 try_get,
11 class MarkizaIE(InfoExtractor):
12 _WORKING = False
13 _VALID_URL = r'https?://(?:www\.)?videoarchiv\.markiza\.sk/(?:video/(?:[^/]+/)*|embed/)(?P<id>\d+)(?:[_/]|$)'
14 _TESTS = [{
15 'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723_oteckovia-109',
16 'md5': 'ada4e9fad038abeed971843aa028c7b0',
17 'info_dict': {
18 'id': '139078',
19 'ext': 'mp4',
20 'title': 'Oteckovia 109',
21 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
22 'thumbnail': r're:^https?://.*\.jpg$',
23 'duration': 2760,
25 }, {
26 'url': 'http://videoarchiv.markiza.sk/video/televizne-noviny/televizne-noviny/85430_televizne-noviny',
27 'info_dict': {
28 'id': '85430',
29 'title': 'Televízne noviny',
31 'playlist_count': 23,
32 }, {
33 'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723',
34 'only_matching': True,
35 }, {
36 'url': 'http://videoarchiv.markiza.sk/video/84723',
37 'only_matching': True,
38 }, {
39 'url': 'http://videoarchiv.markiza.sk/video/filmy/85190_kamenak',
40 'only_matching': True,
41 }, {
42 'url': 'http://videoarchiv.markiza.sk/video/reflex/zo-zakulisia/84651_pribeh-alzbetky',
43 'only_matching': True,
44 }, {
45 'url': 'http://videoarchiv.markiza.sk/embed/85295',
46 'only_matching': True,
49 def _real_extract(self, url):
50 video_id = self._match_id(url)
52 data = self._download_json(
53 'http://videoarchiv.markiza.sk/json/video_jwplayer7.json',
54 video_id, query={'id': video_id})
56 info = self._parse_jwplayer_data(data, m3u8_id='hls', mpd_id='dash')
58 if info.get('_type') == 'playlist':
59 info.update({
60 'id': video_id,
61 'title': try_get(
62 data, lambda x: x['details']['name'], str),
64 else:
65 info['duration'] = parse_duration(
66 try_get(data, lambda x: x['details']['duration'], str))
67 return info
70 class MarkizaPageIE(InfoExtractor):
71 _WORKING = False
72 _VALID_URL = r'https?://(?:www\.)?(?:(?:[^/]+\.)?markiza|tvnoviny)\.sk/(?:[^/]+/)*(?P<id>\d+)_'
73 _TESTS = [{
74 'url': 'http://www.markiza.sk/soubiz/zahranicny/1923705_oteckovia-maju-svoj-den-ti-slavni-nie-su-o-nic-menej-rozkosni',
75 'md5': 'ada4e9fad038abeed971843aa028c7b0',
76 'info_dict': {
77 'id': '139355',
78 'ext': 'mp4',
79 'title': 'Oteckovia 110',
80 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
81 'thumbnail': r're:^https?://.*\.jpg$',
82 'duration': 2604,
84 'params': {
85 'skip_download': True,
87 }, {
88 'url': 'http://dajto.markiza.sk/filmy-a-serialy/1774695_frajeri-vo-vegas',
89 'only_matching': True,
90 }, {
91 'url': 'http://superstar.markiza.sk/aktualne/1923870_to-je-ale-telo-spevacka-ukazala-sexy-postavicku-v-bikinach',
92 'only_matching': True,
93 }, {
94 'url': 'http://hybsa.markiza.sk/aktualne/1923790_uzasna-atmosfera-na-hybsa-v-poprade-superstaristi-si-prve-koncerty-pred-davom-ludi-poriadne-uzili',
95 'only_matching': True,
96 }, {
97 'url': 'http://doma.markiza.sk/filmy/1885250_moja-vysnivana-svadba',
98 'only_matching': True,
99 }, {
100 'url': 'http://www.tvnoviny.sk/domace/1923887_po-smrti-manzela-ju-cakalo-poriadne-prekvapenie',
101 'only_matching': True,
104 @classmethod
105 def suitable(cls, url):
106 return False if MarkizaIE.suitable(url) else super().suitable(url)
108 def _real_extract(self, url):
109 playlist_id = self._match_id(url)
111 webpage = self._download_webpage(
112 # Downloading for some hosts (e.g. dajto, doma) fails with 500
113 # although everything seems to be OK, so considering 500
114 # status code to be expected.
115 url, playlist_id, expected_status=500)
117 entries = [
118 self.url_result(f'http://videoarchiv.markiza.sk/video/{video_id}')
119 for video_id in orderedSet(re.findall(
120 r'(?:initPlayer_|data-entity=["\']|id=["\']player_)(\d+)',
121 webpage))]
123 return self.playlist_result(entries, playlist_id)