1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 19:52:11 +00:00

[markiza] Fixed extractor

This commit is contained in:
Jastrab 2022-01-16 15:40:59 +01:00
parent 4cf557e765
commit 98fb8efcb8

View file

@ -1,20 +1,21 @@
# 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 ..utils import ( from ..utils import (
orderedSet, orderedSet,
url_or_none, url_or_none,
determine_ext determine_ext,
try_get,
compat_str
) )
class MarkizaIE(InfoExtractor): class MarkizaIE(InfoExtractor):
_VALID_URL = r'https:\/\/(?:www\.)?videoarchiv\.markiza\.sk\/(?:video\/(?:[^\/]+\/)*|embed\/)epizoda\/(?P<id>\d+)(?:[\_\/\-]|$)' _VALID_URL = r'https?://(?:www\.)?videoarchiv\.markiza\.sk/(?:video/(?:[^/]+/)*|embed/)\S+/(?P<id>\d+)(?:[_/-]|$)'
_TESTS = [{ _TESTS = [{
'url': 'http://videoarchiv.markiza.sk/video/oteckovia/\ 'url': 'http://videoarchiv.markiza.sk/video/oteckovia/\
84723_oteckovia-109', 84723_oteckovia-109',
@ -52,31 +53,37 @@ class MarkizaIE(InfoExtractor):
}] }]
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) webpage = self._download_webpage(url, video_id)
embed = self._search_regex( embed = self._search_regex(
r'<iframe src="(https:\/\/media.*?)" style="', r'<iframe src="(https:\/\/media.*?)" style="',
webpage, 'embed', fatal=False) webpage, 'embed', fatal=False)
webpage = self._download_webpage(embed, video_id) webpage = self._download_webpage(embed, video_id)
data = self._search_regex( data = self._search_regex(
r'processAdTagModifier\((\{.*)\), {"video":', r'processAdTagModifier\s*\(\s*(\{.*)\)\s*,\s*\{\s*"video"\s*:',
webpage, 'embed', fatal=False) webpage, 'embed', default='')
data2 = self._search_regex( data2 = self._search_regex(
r'processAdTagModifier\(\{.*\), ({"video":.*)\);', r'processAdTagModifier\s*\(\s*\{.*\)\s*,\s*(\{\s*"video"\s*:.*)\s*\);',
webpage, 'embed', fatal=False) webpage, 'embed', default='')
data = re.sub('\\\\/', '/', data) data = re.sub('\\\\/', '/', data)
data2 = re.sub('\\\\/', '/', data2) data2 = re.sub('\\\\/', '/', data2)
info = json.loads(data) info = self._parse_json(data, video_id)
info2 = json.loads(data2) info2 = self._parse_json(data2, video_id)
formats = [] formats = []
for format_id, format_list in info['tracks'].items(): for format_id, format_list in (
if not isinstance(format_list, list): try_get(info, lambda x: x['tracks'], dict) or {}).items():
format_list = [format_list]
for format_dict in format_list: for format_dict in format_list:
if not isinstance(format_dict, dict): if not isinstance(format_dict, dict):
continue continue
format_url = url_or_none(format_dict.get('src')) format_url = try_get(
format_dict, lambda x: url_or_none(x['src']))
if not format_url:
continue
format_type = format_dict.get('type') format_type = format_dict.get('type')
ext = determine_ext(format_url) ext = determine_ext(format_url)
if (format_type == 'application/x-mpegURL' if (format_type == 'application/x-mpegURL'
@ -93,14 +100,23 @@ class MarkizaIE(InfoExtractor):
formats.append({ formats.append({
'url': format_url, 'url': format_url,
}) })
thumbnail = info.get('plugins').get('thumbnails').get('url') # thumbnail = info.get('plugins').get('thumbnails').get('url')
thumbnail = try_get(
info, lambda x: x['plugins']['thumbnails']['url'], compat_str)
thumbnail = re.sub('$Num$', '001', thumbnail) thumbnail = re.sub('$Num$', '001', thumbnail)
duration = info.get('duration') duration = info.get('duration')
title2 = info2.get('video').get('title') # title2 = info2.get('video').get('title')
title = info2.get('video').get('custom').get('show_title') # title = info2.get('video').get('custom').get('show_title')
title2 = try_get(info2, lambda x: x['video']['title'], compat_str)
title = try_get(
info2, lambda x: x['video']['custom']['show_title'], compat_str)
title = ' - '.join(x for x in (title, title2, ) if x)
# if not title:
# continue
return { return {
'id': video_id, 'id': video_id,
'title': title + ' - ' + title2, 'title': title,
'thumbnail': thumbnail, 'thumbnail': thumbnail,
'duration': duration, 'duration': duration,
'formats': formats 'formats': formats
@ -127,8 +143,7 @@ class MarkizaPageIE(InfoExtractor):
'url': 'https://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': 'https://superstar.markiza.sk/aktualne/\ 'url': 'https://superstar.markiza.sk/aktualne/1923870_to-je-ale-telo-spevacka-ukazala-sexy-postavicku-v-bikinach',
1923870_to-je-ale-telo-spevacka-ukazala-sexy-postavicku-v-bikinach',
'only_matching': True, 'only_matching': True,
}, { }, {
'url': 'https://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',
@ -143,8 +158,10 @@ class MarkizaPageIE(InfoExtractor):
@classmethod @classmethod
def suitable(cls, url): def suitable(cls, url):
return False if MarkizaIE.suitable(url) else \ return (
super(MarkizaPageIE, cls).suitable(url) 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)