1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-16 22:37:35 +00:00

[markiza] Fixed extractor

This commit is contained in:
Jastrab 2022-01-15 21:27:57 +01:00
parent 63af7465cc
commit 4cf557e765

View File

@ -1,21 +1,23 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
# update 15.01.2022 jastrab
import re import re
import json
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import compat_str
from ..utils import ( from ..utils import (
orderedSet, orderedSet,
parse_duration, url_or_none,
try_get, determine_ext
) )
class MarkizaIE(InfoExtractor): class MarkizaIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?videoarchiv\.markiza\.sk/(?:video/(?:[^/]+/)*|embed/)(?P<id>\d+)(?:[_/]|$)' _VALID_URL = r'https:\/\/(?:www\.)?videoarchiv\.markiza\.sk\/(?:video\/(?:[^\/]+\/)*|embed\/)epizoda\/(?P<id>\d+)(?:[\_\/\-]|$)'
_TESTS = [{ _TESTS = [{
'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723_oteckovia-109', 'url': 'http://videoarchiv.markiza.sk/video/oteckovia/\
84723_oteckovia-109',
'md5': 'ada4e9fad038abeed971843aa028c7b0', 'md5': 'ada4e9fad038abeed971843aa028c7b0',
'info_dict': { 'info_dict': {
'id': '139078', 'id': '139078',
@ -26,54 +28,89 @@ class MarkizaIE(InfoExtractor):
'duration': 2760, 'duration': 2760,
}, },
}, { }, {
'url': 'http://videoarchiv.markiza.sk/video/televizne-noviny/televizne-noviny/85430_televizne-noviny', 'url': ' https://videoarchiv.markiza.sk/video/laska-na-prenajom/epizoda/58779-seria-1-epizoda-14',
'info_dict': { 'info_dict': {
'id': '85430', 'id': '85430',
'title': 'Televízne noviny', 'title': 'Televízne noviny',
}, },
'playlist_count': 23, 'playlist_count': 23,
}, { }, {
'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723', 'url': 'https://videoarchiv.markiza.sk/video/oteckovia/84723',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://videoarchiv.markiza.sk/video/84723', 'url': 'https://videoarchiv.markiza.sk/video/84723',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://videoarchiv.markiza.sk/video/filmy/85190_kamenak', 'url': 'https://videoarchiv.markiza.sk/video/filmy/85190_kamenak',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://videoarchiv.markiza.sk/video/reflex/zo-zakulisia/84651_pribeh-alzbetky', 'url': 'https://videoarchiv.markiza.sk/video/reflex/zo-zakulisia/84651_pribeh-alzbetky',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://videoarchiv.markiza.sk/embed/85295', 'url': 'https://videoarchiv.markiza.sk/embed/85295',
'only_matching': True, 'only_matching': True,
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
embed = self._search_regex(
r'<iframe src="(https:\/\/media.*?)" style="',
webpage, 'embed', fatal=False)
webpage = self._download_webpage(embed, video_id)
data = self._search_regex(
r'processAdTagModifier\((\{.*)\), {"video":',
webpage, 'embed', fatal=False)
data2 = self._search_regex(
r'processAdTagModifier\(\{.*\), ({"video":.*)\);',
webpage, 'embed', fatal=False)
data = re.sub('\\\\/', '/', data)
data2 = re.sub('\\\\/', '/', data2)
info = json.loads(data)
info2 = json.loads(data2)
data = self._download_json( formats = []
'http://videoarchiv.markiza.sk/json/video_jwplayer7.json', for format_id, format_list in info['tracks'].items():
video_id, query={'id': video_id}) if not isinstance(format_list, list):
format_list = [format_list]
info = self._parse_jwplayer_data(data, m3u8_id='hls', mpd_id='dash') for format_dict in format_list:
if not isinstance(format_dict, dict):
if info.get('_type') == 'playlist': continue
info.update({ format_url = url_or_none(format_dict.get('src'))
'id': video_id, format_type = format_dict.get('type')
'title': try_get( ext = determine_ext(format_url)
data, lambda x: x['details']['name'], compat_str), if (format_type == 'application/x-mpegURL'
}) or format_id == 'HLS' or ext == 'm3u8'):
else: formats.extend(self._extract_m3u8_formats(
info['duration'] = parse_duration( format_url, video_id, 'mp4',
try_get(data, lambda x: x['details']['duration'], compat_str)) entry_protocol='m3u8_native', m3u8_id='hls',
return info fatal=False))
elif (format_type == 'application/dash+xml'
or format_id == 'DASH' or ext == 'mpd'):
formats.extend(self._extract_mpd_formats(
format_url, video_id, mpd_id='dash', fatal=False))
else:
formats.append({
'url': format_url,
})
thumbnail = info.get('plugins').get('thumbnails').get('url')
thumbnail = re.sub('$Num$', '001', thumbnail)
duration = info.get('duration')
title2 = info2.get('video').get('title')
title = info2.get('video').get('custom').get('show_title')
return {
'id': video_id,
'title': title + ' - ' + title2,
'thumbnail': thumbnail,
'duration': duration,
'formats': formats
}
class MarkizaPageIE(InfoExtractor): class MarkizaPageIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?(?:(?:[^/]+\.)?markiza|tvnoviny)\.sk/(?:[^/]+/)*(?P<id>\d+)_' _VALID_URL = r'https?://(?:www\.)?(?:(?:[^/]+\.)?markiza|tvnoviny)\.sk/(?:[^/]+/)*(?P<id>\d+)_'
_TESTS = [{ _TESTS = [{
'url': 'http://www.markiza.sk/soubiz/zahranicny/1923705_oteckovia-maju-svoj-den-ti-slavni-nie-su-o-nic-menej-rozkosni', 'url': 'https://www.markiza.sk/soubiz/zahranicny/1923705_oteckovia-maju-svoj-den-ti-slavni-nie-su-o-nic-menej-rozkosni',
'md5': 'ada4e9fad038abeed971843aa028c7b0', 'md5': 'ada4e9fad038abeed971843aa028c7b0',
'info_dict': { 'info_dict': {
'id': '139355', 'id': '139355',
@ -87,29 +124,30 @@ class MarkizaPageIE(InfoExtractor):
'skip_download': True, 'skip_download': True,
}, },
}, { }, {
'url': 'http://dajto.markiza.sk/filmy-a-serialy/1774695_frajeri-vo-vegas', 'url': 'https://dajto.markiza.sk/filmy-a-serialy/1774695_frajeri-vo-vegas',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://superstar.markiza.sk/aktualne/1923870_to-je-ale-telo-spevacka-ukazala-sexy-postavicku-v-bikinach', 'url': 'https://superstar.markiza.sk/aktualne/\
1923870_to-je-ale-telo-spevacka-ukazala-sexy-postavicku-v-bikinach',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://hybsa.markiza.sk/aktualne/1923790_uzasna-atmosfera-na-hybsa-v-poprade-superstaristi-si-prve-koncerty-pred-davom-ludi-poriadne-uzili', 'url': 'https://hybsa.markiza.sk/aktualne/1923790_uzasna-atmosfera-na-hybsa-v-poprade-superstaristi-si-prve-koncerty-pred-davom-ludi-poriadne-uzili',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://doma.markiza.sk/filmy/1885250_moja-vysnivana-svadba', 'url': 'https://doma.markiza.sk/filmy/1885250_moja-vysnivana-svadba',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'http://www.tvnoviny.sk/domace/1923887_po-smrti-manzela-ju-cakalo-poriadne-prekvapenie', 'url': 'https://www.tvnoviny.sk/domace/1923887_po-smrti-manzela-ju-cakalo-poriadne-prekvapenie',
'only_matching': True, 'only_matching': True,
}] }]
@classmethod @classmethod
def suitable(cls, url): def suitable(cls, url):
return False if MarkizaIE.suitable(url) else super(MarkizaPageIE, cls).suitable(url) return False if MarkizaIE.suitable(url) else \
super(MarkizaPageIE, cls).suitable(url)
def _real_extract(self, url): def _real_extract(self, url):
playlist_id = self._match_id(url) playlist_id = self._match_id(url)
webpage = self._download_webpage( webpage = self._download_webpage(
# Downloading for some hosts (e.g. dajto, doma) fails with 500 # Downloading for some hosts (e.g. dajto, doma) fails with 500
# although everything seems to be OK, so considering 500 # although everything seems to be OK, so considering 500
@ -117,7 +155,8 @@ class MarkizaPageIE(InfoExtractor):
url, playlist_id, expected_status=500) url, playlist_id, expected_status=500)
entries = [ entries = [
self.url_result('http://videoarchiv.markiza.sk/video/%s' % video_id) self.url_result(
'http://videoarchiv.markiza.sk/video/%s' % video_id)
for video_id in orderedSet(re.findall( for video_id in orderedSet(re.findall(
r'(?:initPlayer_|data-entity=["\']|id=["\']player_)(\d+)', r'(?:initPlayer_|data-entity=["\']|id=["\']player_)(\d+)',
webpage))] webpage))]