This commit is contained in:
jastrab 2024-06-27 06:36:17 +08:00 committed by GitHub
commit 839ac95001
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 158 additions and 41 deletions

View File

@ -4,18 +4,21 @@ from __future__ import unicode_literals
import re import re
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,
determine_ext,
try_get, try_get,
compat_str
) )
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/)\S+/(?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 +29,104 @@ 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)
data = self._download_json( webpage = self._download_webpage(url, video_id)
'http://videoarchiv.markiza.sk/json/video_jwplayer7.json',
video_id, query={'id': video_id})
info = self._parse_jwplayer_data(data, m3u8_id='hls', mpd_id='dash') embed = self._search_regex(
r'<iframe src="(https:\/\/media.*?)" style="',
webpage, 'embed', fatal=False)
if info.get('_type') == 'playlist': webpage = self._download_webpage(embed, video_id)
info.update({ data = self._search_regex(
'id': video_id, r'processAdTagModifier\s*\(\s*(\{.*)\)\s*,\s*\{\s*"video"\s*:',
'title': try_get( webpage, 'embed', default='')
data, lambda x: x['details']['name'], compat_str), data2 = self._search_regex(
}) r'processAdTagModifier\s*\(\s*\{.*\)\s*,\s*(\{\s*"video"\s*:.*)\s*\);',
else: webpage, 'embed', default='')
info['duration'] = parse_duration( data = re.sub('\\\\/', '/', data)
try_get(data, lambda x: x['details']['duration'], compat_str)) data2 = re.sub('\\\\/', '/', data2)
return info info = self._parse_json(data, video_id)
info2 = self._parse_json(data2, video_id)
formats = []
for format_id, format_list in (
try_get(info, lambda x: x['tracks'], dict) or {}).items():
for format_dict in format_list:
if not isinstance(format_dict, dict):
continue
format_url = try_get(
format_dict, lambda x: url_or_none(x['src']))
if not format_url:
continue
format_type = format_dict.get('type')
ext = determine_ext(format_url)
if (format_type == 'application/x-mpegURL'
or format_id == 'HLS' or ext == 'm3u8'):
formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls',
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 = try_get(
info, lambda x: x['plugins']['thumbnails']['url'], compat_str)
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')
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 {
'id': video_id,
'title': title,
'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 +140,31 @@ 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 +172,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))]

View File

@ -1,7 +1,13 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import (
url_or_none,
determine_ext
)
class RTVSIE(InfoExtractor): class RTVSIE(InfoExtractor):
@ -26,7 +32,8 @@ class RTVSIE(InfoExtractor):
'id': '63118', 'id': '63118',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Amaro Džives - Náš deň', 'title': 'Amaro Džives - Náš deň',
'description': 'Galavečer pri príležitosti Medzinárodného dňa Rómov.' 'description':
'Galavečer pri príležitosti Medzinárodného dňa Rómov.'
}, },
'params': { 'params': {
'skip_download': True, 'skip_download': True,
@ -36,12 +43,66 @@ class RTVSIE(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) if url.find('/radio/') != -1:
a2 = url.split('/')[-1]
a1 = url.split('/')[-2]
embed = self._download_webpage(
"https://www.rtvs.sk/embed/radio/archive/%s/%s" % (a1, a2),
video_id)
audio_id = re.search('audio5f.json?id=(?P<id>[^\"]+)', embed)
audio_id = audio_id.group('id')
info = self._download_json(
"https://www.rtvs.sk/json/audio5f.json?id=%s" % audio_id,
audio_id)
playlist_url = self._search_regex( formats = []
r'playlist["\']?\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, formats.append({
'playlist url', group='url') 'url': info['playlist'][0]['sources'][0]['src'],
'format_id': None,
'height': 0
})
info = info['playlist'][0]
return {
'id': audio_id,
'title': info.get('title'),
'thumbnail': info.get('image'),
'formats': formats
}
else:
info = self._download_json(
"https://www.rtvs.sk/json/archive5f.json?id=%s" % video_id,
video_id)
info = info.get('clip')
data = self._download_json( formats = []
playlist_url, video_id, 'Downloading playlist')[0] for format_id, format_list in info.items():
return self._parse_jwplayer_data(data, video_id=video_id) if not isinstance(format_list, list):
format_list = [format_list]
for format_dict in format_list:
if not isinstance(format_dict, dict):
continue
format_url = url_or_none(format_dict.get('src'))
format_type = format_dict.get('type')
ext = determine_ext(format_url)
if (format_type == 'application/x-mpegURL'
or format_id == 'HLS' or ext == 'm3u8'):
formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls',
fatal=False))
elif (format_type == 'application/dash+xml'
or format_id == 'DASH' or ext == 'mpd'):
pass
else:
formats.append({
'url': format_url,
})
formats = sorted(formats, key=lambda i: i['tbr'])
dt = info.get('datetime_create')
return {
'id': video_id,
'title': info.get('title') + '-' + dt[:10],
'thumbnail': info.get('image'),
'description': info.get('description'),
'formats': formats
}