Compare commits

...

4 Commits

Author SHA1 Message Date
Mozi
f2ec17c73d
Merge 507b7c6d4a into f2a4983df7 2024-11-13 01:47:06 +01:00
Jackson Humphrey
f2a4983df7
[ie/archive.org] Fix comments extraction (#11527)
Closes #11526
Authored by: jshumphrey
2024-11-12 23:26:18 +00:00
bashonly
bacc31b05a
[ie/facebook] Fix formats extraction (#11513)
Closes #11497
Authored by: bashonly
2024-11-12 23:23:10 +00:00
Mozi
507b7c6d4a [ie/nova:embed] Support live and VOD on markiza.sk and tvnoviny.sk 2024-10-13 10:01:53 +00:00
5 changed files with 226 additions and 139 deletions

View File

@ -1085,10 +1085,6 @@ from .manoto import (
)
from .manyvids import ManyVidsIE
from .maoritv import MaoriTVIE
from .markiza import (
MarkizaIE,
MarkizaPageIE,
)
from .massengeschmacktv import MassengeschmackTVIE
from .masters import MastersIE
from .matchtv import MatchTVIE

View File

@ -205,6 +205,26 @@ class ArchiveOrgIE(InfoExtractor):
},
},
],
}, {
# The reviewbody is None for one of the reviews; just need to extract data without crashing
'url': 'https://archive.org/details/gd95-04-02.sbd.11622.sbeok.shnf/gd95-04-02d1t04.shn',
'info_dict': {
'id': 'gd95-04-02.sbd.11622.sbeok.shnf/gd95-04-02d1t04.shn',
'ext': 'mp3',
'title': 'Stuck Inside of Mobile with the Memphis Blues Again',
'creators': ['Grateful Dead'],
'duration': 338.31,
'track': 'Stuck Inside of Mobile with the Memphis Blues Again',
'description': 'md5:764348a470b986f1217ffd38d6ac7b72',
'display_id': 'gd95-04-02d1t04.shn',
'location': 'Pyramid Arena',
'uploader': 'jon@archive.org',
'album': '1995-04-02 - Pyramid Arena',
'upload_date': '20040519',
'track_number': 4,
'release_date': '19950402',
'timestamp': 1084927901,
},
}]
@staticmethod
@ -335,7 +355,7 @@ class ArchiveOrgIE(InfoExtractor):
info['comments'].append({
'id': review.get('review_id'),
'author': review.get('reviewer'),
'text': str_or_none(review.get('reviewtitle'), '') + '\n\n' + review.get('reviewbody'),
'text': join_nonempty('reviewtitle', 'reviewbody', from_dict=review, delim='\n\n'),
'timestamp': unified_timestamp(review.get('createdate')),
'parent': 'root'})

View File

@ -563,13 +563,13 @@ class FacebookIE(InfoExtractor):
return extract_video_data(try_get(
js_data, lambda x: x['jsmods']['instances'], list) or [])
def extract_dash_manifest(video, formats):
def extract_dash_manifest(vid_data, formats, mpd_url=None):
dash_manifest = traverse_obj(
video, 'dash_manifest', 'playlist', 'dash_manifest_xml_string', expected_type=str)
vid_data, 'dash_manifest', 'playlist', 'dash_manifest_xml_string', 'manifest_xml', expected_type=str)
if dash_manifest:
formats.extend(self._parse_mpd_formats(
compat_etree_fromstring(urllib.parse.unquote_plus(dash_manifest)),
mpd_url=url_or_none(video.get('dash_manifest_url'))))
mpd_url=url_or_none(video.get('dash_manifest_url')) or mpd_url))
def process_formats(info):
# Downloads with browser's User-Agent are rate limited. Working around
@ -619,9 +619,12 @@ class FacebookIE(InfoExtractor):
video = video['creation_story']
video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner'))
video.update(reel_info)
fmt_data = traverse_obj(video, ('videoDeliveryLegacyFields', {dict})) or video
formats = []
q = qualities(['sd', 'hd'])
# Legacy formats extraction
fmt_data = traverse_obj(video, ('videoDeliveryLegacyFields', {dict})) or video
for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'),
('playable_url_dash', ''), ('browser_native_hd_url', 'hd'),
('browser_native_sd_url', 'sd')):
@ -629,7 +632,7 @@ class FacebookIE(InfoExtractor):
if not playable_url:
continue
if determine_ext(playable_url) == 'mpd':
formats.extend(self._extract_mpd_formats(playable_url, video_id))
formats.extend(self._extract_mpd_formats(playable_url, video_id, fatal=False))
else:
formats.append({
'format_id': format_id,
@ -638,6 +641,28 @@ class FacebookIE(InfoExtractor):
'url': playable_url,
})
extract_dash_manifest(fmt_data, formats)
# New videoDeliveryResponse formats extraction
fmt_data = traverse_obj(video, ('videoDeliveryResponseFragment', 'videoDeliveryResponseResult'))
mpd_urls = traverse_obj(fmt_data, ('dash_manifest_urls', ..., 'manifest_url', {url_or_none}))
dash_manifests = traverse_obj(fmt_data, ('dash_manifests', lambda _, v: v['manifest_xml']))
for idx, dash_manifest in enumerate(dash_manifests):
extract_dash_manifest(dash_manifest, formats, mpd_url=traverse_obj(mpd_urls, idx))
if not dash_manifests:
# Only extract from MPD URLs if the manifests are not already provided
for mpd_url in mpd_urls:
formats.extend(self._extract_mpd_formats(mpd_url, video_id, fatal=False))
for prog_fmt in traverse_obj(fmt_data, ('progressive_urls', lambda _, v: v['progressive_url'])):
format_id = traverse_obj(prog_fmt, ('metadata', 'quality', {str.lower}))
formats.append({
'format_id': format_id,
# sd, hd formats w/o resolution info should be deprioritized below DASH
'quality': q(format_id) - 3,
'url': prog_fmt['progressive_url'],
})
for m3u8_url in traverse_obj(fmt_data, ('hls_playlist_urls', ..., 'hls_playlist_url', {url_or_none})):
formats.extend(self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', fatal=False, m3u8_id='hls'))
if not formats:
# Do not append false positive entry w/o any formats
return

View File

@ -1,123 +0,0 @@
import re
from .common import InfoExtractor
from ..utils import (
orderedSet,
parse_duration,
try_get,
)
class MarkizaIE(InfoExtractor):
_WORKING = False
_VALID_URL = r'https?://(?:www\.)?videoarchiv\.markiza\.sk/(?:video/(?:[^/]+/)*|embed/)(?P<id>\d+)(?:[_/]|$)'
_TESTS = [{
'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723_oteckovia-109',
'md5': 'ada4e9fad038abeed971843aa028c7b0',
'info_dict': {
'id': '139078',
'ext': 'mp4',
'title': 'Oteckovia 109',
'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 2760,
},
}, {
'url': 'http://videoarchiv.markiza.sk/video/televizne-noviny/televizne-noviny/85430_televizne-noviny',
'info_dict': {
'id': '85430',
'title': 'Televízne noviny',
},
'playlist_count': 23,
}, {
'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723',
'only_matching': True,
}, {
'url': 'http://videoarchiv.markiza.sk/video/84723',
'only_matching': True,
}, {
'url': 'http://videoarchiv.markiza.sk/video/filmy/85190_kamenak',
'only_matching': True,
}, {
'url': 'http://videoarchiv.markiza.sk/video/reflex/zo-zakulisia/84651_pribeh-alzbetky',
'only_matching': True,
}, {
'url': 'http://videoarchiv.markiza.sk/embed/85295',
'only_matching': True,
}]
def _real_extract(self, url):
video_id = self._match_id(url)
data = self._download_json(
'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')
if info.get('_type') == 'playlist':
info.update({
'id': video_id,
'title': try_get(
data, lambda x: x['details']['name'], str),
})
else:
info['duration'] = parse_duration(
try_get(data, lambda x: x['details']['duration'], str))
return info
class MarkizaPageIE(InfoExtractor):
_WORKING = False
_VALID_URL = r'https?://(?:www\.)?(?:(?:[^/]+\.)?markiza|tvnoviny)\.sk/(?:[^/]+/)*(?P<id>\d+)_'
_TESTS = [{
'url': 'http://www.markiza.sk/soubiz/zahranicny/1923705_oteckovia-maju-svoj-den-ti-slavni-nie-su-o-nic-menej-rozkosni',
'md5': 'ada4e9fad038abeed971843aa028c7b0',
'info_dict': {
'id': '139355',
'ext': 'mp4',
'title': 'Oteckovia 110',
'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 2604,
},
'params': {
'skip_download': True,
},
}, {
'url': 'http://dajto.markiza.sk/filmy-a-serialy/1774695_frajeri-vo-vegas',
'only_matching': True,
}, {
'url': 'http://superstar.markiza.sk/aktualne/1923870_to-je-ale-telo-spevacka-ukazala-sexy-postavicku-v-bikinach',
'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',
'only_matching': True,
}, {
'url': 'http://doma.markiza.sk/filmy/1885250_moja-vysnivana-svadba',
'only_matching': True,
}, {
'url': 'http://www.tvnoviny.sk/domace/1923887_po-smrti-manzela-ju-cakalo-poriadne-prekvapenie',
'only_matching': True,
}]
@classmethod
def suitable(cls, url):
return False if MarkizaIE.suitable(url) else super().suitable(url)
def _real_extract(self, url):
playlist_id = self._match_id(url)
webpage = self._download_webpage(
# Downloading for some hosts (e.g. dajto, doma) fails with 500
# although everything seems to be OK, so considering 500
# status code to be expected.
url, playlist_id, expected_status=500)
entries = [
self.url_result(f'http://videoarchiv.markiza.sk/video/{video_id}')
for video_id in orderedSet(re.findall(
r'(?:initPlayer_|data-entity=["\']|id=["\']player_)(\d+)',
webpage))]
return self.playlist_result(entries, playlist_id)

View File

@ -6,6 +6,7 @@ from ..utils import (
determine_ext,
int_or_none,
js_to_json,
strip_or_none,
traverse_obj,
unified_strdate,
url_or_none,
@ -13,7 +14,12 @@ from ..utils import (
class NovaEmbedIE(InfoExtractor):
_VALID_URL = r'https?://media(?:tn)?\.cms\.nova\.cz/embed/(?P<id>[^/?#&]+)'
_DOMAINS = [
r'media(?:tn)?\.cms\.nova\.cz',
r'media\.cms\.(?:markiza|tvnoviny)\.sk',
]
_VALID_URL = [rf'https?://{domain}/embed/(?P<id>[^/?#&"\']+)' for domain in _DOMAINS]
_EMBED_REGEX = [rf'(?x)<iframe[^>]+\b(?:data-)?src=["\'](?P<url>{url})' for url in _VALID_URL]
_TESTS = [{
'url': 'https://media.cms.nova.cz/embed/8o0n0r?autoplay=1',
'info_dict': {
@ -43,19 +49,179 @@ class NovaEmbedIE(InfoExtractor):
'id': 'EU5ELEsmOHt',
'ext': 'mp4',
'title': 'Haptické křeslo, bionická ruka nebo roboti. Reportérka se podívala na Týden inovací',
'thumbnail': r're:^https?://.*\.jpg',
'thumbnail': r're:^https?://cloudia\.cms\.nova\.cz/.+',
'duration': 1780,
},
'params': {'skip_download': 'm3u8'},
}]
_WEBPAGE_TESTS = [{
'url': 'http://www.markiza.sk/soubiz/zahranicny/1923705_oteckovia-maju-svoj-den-ti-slavni-nie-su-o-nic-menej-rozkosni',
'md5': 'a478390ea7f36aeb36004a107db8b031',
'info_dict': {
'id': '4q3zP2DsORO',
'ext': 'mp4',
'title': 'Oteckovia 110',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 2603,
},
}, {
'url': 'https://tvnoviny.sk/domace/clanok/141815-byvaly-sportovec-udajne-vyrabal-mast-z-marihuany-sud-mu-vymeral-20-rocny-trest-a-vzal-aj-rodinny-dom',
'md5': '51de0754352a36b4d623f98c9636a5e1',
'info_dict': {
'id': '2LcfYRqGuYP',
'ext': 'mp4',
'title': 'Marihuanový mastičkár si vypočul vysoký trest a prepad majetku',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 119,
},
}, {
'url': 'https://tvnoviny.sk/domace/clanok/144055-robert-z-kosic-dostal-najnizsi-mozny-trest-za-to-co-spravil-je-to-aj-tak-vela-tvrdia-blizki',
'md5': 'c9a8467b37951877336a9ae6309558b0',
'info_dict': {
'id': '82N7FrJK7cR',
'ext': 'mp4',
'title': 'Robovi z Košíc znížili trest za marihuanu, odsúdili ho na päť rokov',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 152,
},
}, {
'url': 'https://tvnoviny.sk/domace/clanok/338907-preco-sa-mnozia-utoky-tinedzerov-podla-psychologiciek-je-za-tym-rastuca-frustracia',
'md5': '869b589e99d7c19dd66f024a7d088502',
'info_dict': {
'id': 'DeiezcjCJmg',
'ext': 'mp4',
'title': '2022-11-03-TN-2-Nasilie-medzi-mladymi',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 142,
},
}, {
'url': 'http://tvnoviny.sk/domace/clanok/890183-vlada-chysta-postavit-novu-nemocnicu-v-presove-informoval-premier-robert-fico',
'md5': 'b9ef0b4917deee2c930f2248b568a90c',
'info_dict': {
'id': '7VCyuyfGsNZ',
'ext': 'mp4',
'title': '2024-04-15-PTN-1-Co-caka-zdravotnictvo',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 137,
},
}, {
'url': 'https://www.markiza.sk/live/1-markiza',
'info_dict': {
'id': 'markiza-live',
'ext': 'mp4',
'title': r're:^CRA Markiza SD \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
'thumbnail': r're:^https?://cloudia\.cms\.markiza\.sk/.+',
'live_status': 'is_live',
},
}, {
'url': 'http://www.tvnoviny.sk/domace/1923887_po-smrti-manzela-ju-cakalo-poriadne-prekvapenie',
'md5': 'e3e0f1e98172ea64147cada308276df8',
'info_dict': {
'id': 'JxqRvQkFwHK',
'ext': 'mp4',
'title': 'Po smrti manžela ju čakalo prekvapenie',
'thumbnail': r're:^https?://.*\.(?:jpg)',
'duration': 108,
},
}, {
'url': 'http://videoarchiv.markiza.sk/video/reflex/zo-zakulisia/84651_pribeh-alzbetky',
'md5': 'b40d04d5cb4cf529e2ff14d6726a3548',
'info_dict': {
'id': '9ZnlOQp2MRa',
'ext': 'mp4',
'title': 'Príbeh Alžbetky',
'thumbnail': r're:^https?://.*\.(?:jpg)',
'duration': 361,
},
}, {
'url': 'https://www.markiza.sk/relacie/superstar/clanok/549972-v-zakulisi-superstar-to-bolo-obcas-drsne-moderator-priznal-ze-musel-pouzit-aj-hrubu-silu',
'info_dict': {
'id': '549972-v-zakulisi-superstar-to-bolo-obcas-drsne-moderator-priznal-ze-musel-pouzit-aj-hrubu-silu',
'title': 'V zákulisí SuperStar to bolo občas drsné. Moderátor priznal, že musel použiť aj hrubú silu | TV Markíza',
'description': 'md5:02e240e302bddfd0cd352bc886d95161',
'thumbnail': r're:^https?://cmesk-ott-images-avod\.ssl\.cdn\.cra\.cz/.+',
'age_limit': 0,
},
'playlist_count': 2,
}, {
'url': 'https://voyo.markiza.sk/filmy/6702-vysnivana-svadba',
'info_dict': {
'id': '20kSOHBD8DQ',
'title': 'Vysnívaná svadba - 0000',
'thumbnail': r're:^https?://.*\.(?:jpg)',
'duration': 4924,
},
'params': {
'skip_download': True,
'ignore_no_formats_error': True,
},
'expected_warnings': [
'Requested format is not available',
'This video is DRM protected',
],
'skip': 'premium member only',
}, {
# Another URLs:
# http://videoarchiv.markiza.sk/video/84723
'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723_oteckovia-109',
'info_dict': {
'id': '2a5fQmhjvYm',
'title': 'Oteckovia 109',
'thumbnail': r're:^https?://.*\.(?:jpg)',
'duration': 2759,
},
'params': {
'skip_download': True,
'ignore_no_formats_error': True,
},
'expected_warnings': [
'Requested format is not available',
'This video is DRM protected',
],
'skip': 'premium member only',
}, {
'url': 'https://voyo.markiza.sk/filmy/1377-frajeri-vo-vegas#player-fullscreen',
'info_dict': {
'id': '1377-frajeri-vo-vegas#player-fullscreen',
'title': 'Frajeri vo Vegas | Voyo',
'description': 'md5:7f16168f669f144986d862312949627c',
'thumbnail': r're:^https?://cmesk-ott-images-svod\.ssl\.cdn\.cra\.cz/.+',
'age_limit': 0,
},
'playlist': [{
'info_dict': {
'id': 'K8H4IvKNBbw',
'ext': 'mp4',
'title': 'frajeri-vo-vegas-hd-15_frajeri-trailer',
'duration': 90,
'thumbnail': r're:^https?://.*\.(?:jpg)',
},
},
# BUG: The 2nd item (CDjGcqcCYKy) is the movie itself and it's DRM-protected.
# The "ext" field can neither be here nor omitted.
],
'playlist_count': 2,
'params': {
'skip_download': True,
'ignore_no_formats_error': True,
},
'expected_warnings': [
'Requested format is not available',
'This video is DRM protected',
],
'skip': 'premium member only',
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
if 'player_not_logged_in' in webpage:
self.raise_login_required()
has_drm = False
duration = None
is_live = False
formats = []
def process_format_list(format_list, format_id=''):
@ -77,11 +243,11 @@ class NovaEmbedIE(InfoExtractor):
formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls',
fatal=False))
fatal=False, headers={'Referer': url}))
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))
format_url, video_id, mpd_id='dash', fatal=False, headers={'Referer': url}))
else:
formats.append({
'url': format_url,
@ -93,6 +259,7 @@ class NovaEmbedIE(InfoExtractor):
for src in traverse_obj(player, ('lib', 'source', 'sources', ...)):
process_format_list(src)
duration = traverse_obj(player, ('sourceInfo', 'duration', {int_or_none}))
is_live = player.get('isLive', False)
if not formats and not has_drm:
# older code path, in use before August 2023
player = self._parse_json(
@ -108,11 +275,11 @@ class NovaEmbedIE(InfoExtractor):
if not formats and has_drm:
self.report_drm(video_id)
title = self._og_search_title(
title = strip_or_none(self._og_search_title(
webpage, default=None) or self._search_regex(
(r'<value>(?P<title>[^<]+)',
r'videoTitle\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1'), webpage,
'title', group='value')
'title', group='value'))
thumbnail = self._og_search_thumbnail(
webpage, default=None) or self._search_regex(
r'poster\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1', webpage,
@ -127,6 +294,8 @@ class NovaEmbedIE(InfoExtractor):
'thumbnail': thumbnail,
'duration': duration,
'formats': formats,
'http_headers': {'Referer': url},
'is_live': is_live,
}