mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 09:11:25 +01:00
Compare commits
5 Commits
bf8ccc41a7
...
a8a6829399
Author | SHA1 | Date | |
---|---|---|---|
|
a8a6829399 | ||
|
f2a4983df7 | ||
|
bacc31b05a | ||
|
a9f85670d0 | ||
|
513d4c358e |
|
@ -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
|
@staticmethod
|
||||||
|
@ -335,7 +355,7 @@ class ArchiveOrgIE(InfoExtractor):
|
||||||
info['comments'].append({
|
info['comments'].append({
|
||||||
'id': review.get('review_id'),
|
'id': review.get('review_id'),
|
||||||
'author': review.get('reviewer'),
|
'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')),
|
'timestamp': unified_timestamp(review.get('createdate')),
|
||||||
'parent': 'root'})
|
'parent': 'root'})
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from ..utils import (
|
||||||
|
|
||||||
|
|
||||||
class ChaturbateIE(InfoExtractor):
|
class ChaturbateIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:[^/]+\.)?chaturbate\.com/(?:fullvideo/?\?.*?\bb=)?(?P<id>[^/?&#]+)'
|
_VALID_URL = r'https?://(?:[^/]+\.)?chaturbate\.(?P<tld>com|eu|global)/(?:fullvideo/?\?.*?\bb=)?(?P<id>[^/?&#]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.chaturbate.com/siswet19/',
|
'url': 'https://www.chaturbate.com/siswet19/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -29,15 +29,24 @@ class ChaturbateIE(InfoExtractor):
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://en.chaturbate.com/siswet19/',
|
'url': 'https://en.chaturbate.com/siswet19/',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://chaturbate.eu/siswet19/',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://chaturbate.eu/fullvideo/?b=caylin',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://chaturbate.global/siswet19/',
|
||||||
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_ROOM_OFFLINE = 'Room is currently offline'
|
_ROOM_OFFLINE = 'Room is currently offline'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id, tld = self._match_valid_url(url).group('id', 'tld')
|
||||||
|
|
||||||
webpage = self._download_webpage(
|
webpage = self._download_webpage(
|
||||||
f'https://chaturbate.com/{video_id}/', video_id,
|
f'https://chaturbate.{tld}/{video_id}/', video_id,
|
||||||
headers=self.geo_verification_headers())
|
headers=self.geo_verification_headers())
|
||||||
|
|
||||||
found_m3u8_urls = []
|
found_m3u8_urls = []
|
||||||
|
|
|
@ -563,13 +563,13 @@ class FacebookIE(InfoExtractor):
|
||||||
return extract_video_data(try_get(
|
return extract_video_data(try_get(
|
||||||
js_data, lambda x: x['jsmods']['instances'], list) or [])
|
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(
|
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:
|
if dash_manifest:
|
||||||
formats.extend(self._parse_mpd_formats(
|
formats.extend(self._parse_mpd_formats(
|
||||||
compat_etree_fromstring(urllib.parse.unquote_plus(dash_manifest)),
|
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):
|
def process_formats(info):
|
||||||
# Downloads with browser's User-Agent are rate limited. Working around
|
# Downloads with browser's User-Agent are rate limited. Working around
|
||||||
|
@ -619,9 +619,12 @@ class FacebookIE(InfoExtractor):
|
||||||
video = video['creation_story']
|
video = video['creation_story']
|
||||||
video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner'))
|
video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner'))
|
||||||
video.update(reel_info)
|
video.update(reel_info)
|
||||||
fmt_data = traverse_obj(video, ('videoDeliveryLegacyFields', {dict})) or video
|
|
||||||
formats = []
|
formats = []
|
||||||
q = qualities(['sd', 'hd'])
|
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'),
|
for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'),
|
||||||
('playable_url_dash', ''), ('browser_native_hd_url', 'hd'),
|
('playable_url_dash', ''), ('browser_native_hd_url', 'hd'),
|
||||||
('browser_native_sd_url', 'sd')):
|
('browser_native_sd_url', 'sd')):
|
||||||
|
@ -629,7 +632,7 @@ class FacebookIE(InfoExtractor):
|
||||||
if not playable_url:
|
if not playable_url:
|
||||||
continue
|
continue
|
||||||
if determine_ext(playable_url) == 'mpd':
|
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:
|
else:
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
|
@ -638,6 +641,28 @@ class FacebookIE(InfoExtractor):
|
||||||
'url': playable_url,
|
'url': playable_url,
|
||||||
})
|
})
|
||||||
extract_dash_manifest(fmt_data, formats)
|
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:
|
if not formats:
|
||||||
# Do not append false positive entry w/o any formats
|
# Do not append false positive entry w/o any formats
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,182 +1,290 @@
|
||||||
import re
|
import functools
|
||||||
|
|
||||||
from .srgssr import SRGSSRIE
|
from .srgssr import SRGSSRIE
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
determine_ext,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_duration,
|
orderedSet,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
unescapeHTML,
|
parse_resolution,
|
||||||
urljoin,
|
|
||||||
)
|
)
|
||||||
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
|
class RTSIE(SRGSSRIE):
|
||||||
_WORKING = False
|
_GEO_COUNTRIES = ['CH']
|
||||||
IE_DESC = 'RTS.ch'
|
IE_DESC = 'RTS.ch'
|
||||||
_VALID_URL = r'rts:(?P<rts_id>\d+)|https?://(?:.+?\.)?rts\.ch/(?:[^/]+/){2,}(?P<id>[0-9]+)-(?P<display_id>.+?)\.html'
|
_VALID_URL = [
|
||||||
|
r'rts:(?P<id>\d+)',
|
||||||
|
r'https?://(?:.+?\.)?rts\.ch/(?:[^/]+/){2,}(?P<id>[0-9]+)-(?P<display_id>.+?)\.html',
|
||||||
|
r'https?://(?:.+?\.)?rts\.ch/(?:[^/]+/){2,}(?P<display_id>.+?)-(?P<id>[0-9]+)\.html',
|
||||||
|
]
|
||||||
|
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
{
|
{
|
||||||
|
# article with videos
|
||||||
'url': 'http://www.rts.ch/archives/tv/divers/3449373-les-enfants-terribles.html',
|
'url': 'http://www.rts.ch/archives/tv/divers/3449373-les-enfants-terribles.html',
|
||||||
'md5': '753b877968ad8afaeddccc374d4256a5',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '3449373',
|
'id': '3449373',
|
||||||
'display_id': 'les-enfants-terribles',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'duration': 1488,
|
|
||||||
'title': 'Les Enfants Terribles',
|
'title': 'Les Enfants Terribles',
|
||||||
'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.',
|
'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.',
|
||||||
'uploader': 'Divers',
|
'display_id': 'les-enfants-terribles',
|
||||||
|
'tags': ['Divers', 'Archives TV', 'Culture et Arts', 'Les archives', 'Personnalités', 'RTS Archives', 'Années 1960', 'Autres arts', 'Décennies', 'Société'],
|
||||||
|
},
|
||||||
|
'playlist': [{
|
||||||
|
'info_dict': {
|
||||||
|
'id': '3449373',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Les Enfants Terribles',
|
||||||
|
'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
'upload_date': '19680921',
|
'upload_date': '19680921',
|
||||||
'timestamp': -40280400,
|
'timestamp': -40280400,
|
||||||
'thumbnail': r're:^https?://.*\.image',
|
'duration': 1488,
|
||||||
'view_count': int,
|
'categories': ['Divers'],
|
||||||
},
|
},
|
||||||
'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
|
}],
|
||||||
},
|
'params': {'skip_download': 'm3u8'}, # 700-byte first fragment
|
||||||
{
|
|
||||||
'url': 'http://www.rts.ch/emissions/passe-moi-les-jumelles/5624067-entre-ciel-et-mer.html',
|
|
||||||
'info_dict': {
|
|
||||||
'id': '5624065',
|
|
||||||
'title': 'Passe-moi les jumelles',
|
|
||||||
},
|
|
||||||
'playlist_mincount': 4,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
# video without text content
|
||||||
'url': 'http://www.rts.ch/video/sport/hockey/5745975-1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski.html',
|
'url': 'http://www.rts.ch/video/sport/hockey/5745975-1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski.html',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '5745975',
|
'id': '5745975',
|
||||||
'display_id': '1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski',
|
'display_id': '1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski',
|
||||||
'ext': 'mp4',
|
|
||||||
'duration': 48,
|
|
||||||
'title': '1/2, Kloten - Fribourg (5-2): second but pour Gottéron par Kwiatowski',
|
'title': '1/2, Kloten - Fribourg (5-2): second but pour Gottéron par Kwiatowski',
|
||||||
'description': 'Hockey - Playoff',
|
'description': 'Hockey - Playoff',
|
||||||
'uploader': 'Hockey',
|
'tags': ['Hockey', 'Sport', 'RTS Sport'],
|
||||||
|
},
|
||||||
|
'playlist': [{
|
||||||
|
'info_dict': {
|
||||||
|
'id': '5745975',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': '1/2, Kloten - Fribourg (5-2): second but pour Gottéron par Kwiatowski',
|
||||||
|
'description': 'Hockey - Playoff',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
'upload_date': '20140403',
|
'upload_date': '20140403',
|
||||||
'timestamp': 1396556882,
|
'timestamp': 1396556882,
|
||||||
'thumbnail': r're:^https?://.*\.image',
|
'duration': 48,
|
||||||
'view_count': int,
|
'categories': ['Hockey sur glace'],
|
||||||
},
|
},
|
||||||
'params': {
|
}],
|
||||||
# m3u8 download
|
'params': {'skip_download': 'm3u8'}, # 700-byte first fragment
|
||||||
'skip_download': True,
|
|
||||||
},
|
|
||||||
'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
|
|
||||||
'skip': 'Blocked outside Switzerland',
|
'skip': 'Blocked outside Switzerland',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
# video player; redirection: https://www.rts.ch/play/tv/lactu-en-video/video/londres-cachee-par-un-epais-smog?urn=urn:rts:video:5745356
|
||||||
'url': 'http://www.rts.ch/video/info/journal-continu/5745356-londres-cachee-par-un-epais-smog.html',
|
'url': 'http://www.rts.ch/video/info/journal-continu/5745356-londres-cachee-par-un-epais-smog.html',
|
||||||
'md5': '9bb06503773c07ce83d3cbd793cebb91',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '5745356',
|
'id': '5745356',
|
||||||
'display_id': 'londres-cachee-par-un-epais-smog',
|
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'duration': 33,
|
'duration': 33.76,
|
||||||
'title': 'Londres cachée par un épais smog',
|
'title': 'Londres cachée par un épais smog',
|
||||||
'description': 'Un important voile de smog recouvre Londres depuis mercredi, provoqué par la pollution et du sable du Sahara.',
|
'description': 'Un important voile de smog recouvre Londres depuis mercredi, provoqué par la pollution et du sable du Sahara.',
|
||||||
'uploader': 'L\'actu en vidéo',
|
|
||||||
'upload_date': '20140403',
|
'upload_date': '20140403',
|
||||||
'timestamp': 1396537322,
|
'timestamp': 1396537322,
|
||||||
'thumbnail': r're:^https?://.*\.image',
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
'view_count': int,
|
'webpage_url': 'srgssr:rts:video:5745356',
|
||||||
},
|
},
|
||||||
'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'],
|
'params': {'skip_download': 'm3u8'}, # 700-byte first fragment
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
# audio & podcast
|
||||||
'url': 'http://www.rts.ch/audio/couleur3/programmes/la-belle-video-de-stephane-laurenceau/5706148-urban-hippie-de-damien-krisl-03-04-2014.html',
|
'url': 'http://www.rts.ch/audio/couleur3/programmes/la-belle-video-de-stephane-laurenceau/5706148-urban-hippie-de-damien-krisl-03-04-2014.html',
|
||||||
'md5': 'dd8ef6a22dff163d063e2a52bc8adcae',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '5706148',
|
'id': '5706148',
|
||||||
'display_id': 'urban-hippie-de-damien-krisl-03-04-2014',
|
|
||||||
'ext': 'mp3',
|
|
||||||
'duration': 123,
|
|
||||||
'title': '"Urban Hippie", de Damien Krisl',
|
'title': '"Urban Hippie", de Damien Krisl',
|
||||||
'description': 'Des Hippies super glam.',
|
'description': 'Des Hippies super glam.',
|
||||||
'upload_date': '20140403',
|
'display_id': 'urban-hippie-de-damien-krisl',
|
||||||
'timestamp': 1396551600,
|
'tags': ['Media Radio', 'Couleur3'],
|
||||||
},
|
},
|
||||||
|
'playlist': [{
|
||||||
|
'info_dict': {
|
||||||
|
'id': '5706148',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': '"Urban Hippie", de Damien Krisl',
|
||||||
|
'description': 'Des Hippies super glam.',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
|
'upload_date': '20140403',
|
||||||
|
'timestamp': 1396546481,
|
||||||
|
'duration': 123,
|
||||||
|
'categories': ['La belle vidéo de Stéphane Laurenceau'],
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'info_dict': {
|
||||||
|
'id': '5747185',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': 'Le musée du psychédélisme',
|
||||||
|
'description': 'md5:72f8662f48c32050ae817e3bde7e0acc',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
|
'upload_date': '20140402',
|
||||||
|
'timestamp': 1396476000,
|
||||||
|
'duration': 274,
|
||||||
|
'categories': ['Happy Culture'],
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'info_dict': {
|
||||||
|
'id': '5706149',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': 'Silk Art Hippie Culture',
|
||||||
|
'description': 'md5:8e3b9d8d84d85ca8a1905cf50b39bba4',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
|
'upload_date': '20140403',
|
||||||
|
'timestamp': 1396545649,
|
||||||
|
'duration': 161,
|
||||||
|
'categories': ['Happy Pics'],
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'info_dict': {
|
||||||
|
'id': '5706148',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': '"Urban Hippie", de Damien Krisl',
|
||||||
|
'description': 'Des Hippies super glam.',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
|
'upload_date': '20140403',
|
||||||
|
'timestamp': 1396546481,
|
||||||
|
'duration': 123,
|
||||||
|
'categories': ['La belle vidéo de Stéphane Laurenceau'],
|
||||||
|
},
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
# article with videos on rhs
|
# article with videos on rhs
|
||||||
'url': 'http://www.rts.ch/sport/hockey/6693917-hockey-davos-decroche-son-31e-titre-de-champion-de-suisse.html',
|
'url': 'http://www.rts.ch/sport/hockey/6693917-hockey-davos-decroche-son-31e-titre-de-champion-de-suisse.html',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '6693917',
|
'id': '6693917',
|
||||||
'title': 'Hockey: Davos décroche son 31e titre de champion de Suisse',
|
'title': 'Davos décroche le 31e titre de son histoire',
|
||||||
|
'description': 'md5:3c9a767b2a332413eda33c526024578c',
|
||||||
|
'display_id': 'hockey-davos-decroche-son-31e-titre-de-champion-de-suisse',
|
||||||
|
'tags': ['Hockey', 'Tout le sport', 'RTS Info', 'LNA', "Toute l'info", 'RTS Sport'],
|
||||||
},
|
},
|
||||||
'playlist_mincount': 5,
|
'playlist_mincount': 5,
|
||||||
|
'skip': 'Blocked outside Switzerland',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
# articles containing recordings of TV shows
|
||||||
|
'url': 'https://www.rts.ch/info/regions/valais/12865814-un-bouquetin-emporte-par-un-aigle-royal-sur-les-hauts-de-fully-vs.html',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '12865814',
|
||||||
|
'title': 'Un bouquetin emporté par un aigle royal sur les hauts de Fully (VS)',
|
||||||
|
'description': 'md5:9b511f89075e2730bd2dd59915c25574',
|
||||||
|
'display_id': 'un-bouquetin-emporte-par-un-aigle-royal-sur-les-hauts-de-fully-vs',
|
||||||
|
'tags': ['Régions', 'RTS Info', 'Valais', "Toute l'info"],
|
||||||
|
},
|
||||||
|
'playlist': [{
|
||||||
|
'info_dict': {
|
||||||
|
'id': '12861415',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'En Valais, un bouquetin emporté dans les airs par un aigle royal. Décryptage d’une image rare.',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
|
'timestamp': 1644690600,
|
||||||
|
'upload_date': '20220212',
|
||||||
|
'duration': 107,
|
||||||
|
'categories': ['19h30'],
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
'params': {'skip_download': 'm3u8'}, # 700-byte first fragment
|
||||||
|
'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
# new URL format; article with videos
|
||||||
|
'url': 'https://www.rts.ch/info/suisse/2024/article/doris-leuthard-il-y-a-des-alternatives-au-nucleaire-qui-sont-moins-risquees-28631869.html',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '28631869',
|
||||||
|
'title': 'Doris Leuthard: "Il y a des alternatives au nucléaire qui sont moins risquées"',
|
||||||
|
'description': 'md5:ba9930e218dcd177801a34b89a16b86e',
|
||||||
|
'display_id': 'doris-leuthard-il-y-a-des-alternatives-au-nucleaire-qui-sont-moins-risquees',
|
||||||
|
'tags': 'count:13',
|
||||||
|
},
|
||||||
|
'playlist': [{
|
||||||
|
'info_dict': {
|
||||||
|
'id': '15162786',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'L\'invitée de La Matinale (vidéo) - Doris Leuthard, co-présidente du projet d\'exposition nationale Svizra27',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
|
'upload_date': '20240916',
|
||||||
|
'timestamp': 1726462800,
|
||||||
|
'duration': 860,
|
||||||
|
'categories': ['La Matinale'],
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'info_dict': {
|
||||||
|
'id': '15164848',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Le Centre pourrait faire pencher la balance en faveur de la construction de nouvelles centrales nucléaires',
|
||||||
|
'thumbnail': r're:^https?://.*\.image',
|
||||||
|
'upload_date': '20240916',
|
||||||
|
'timestamp': 1726502400,
|
||||||
|
'duration': 227,
|
||||||
|
'categories': ['Forum'],
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
'params': {'skip_download': 'm3u8'}, # 700-byte first fragment
|
||||||
|
'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'url': 'http://pages.rts.ch/emissions/passe-moi-les-jumelles/5624065-entre-ciel-et-mer.html',
|
'url': 'http://pages.rts.ch/emissions/passe-moi-les-jumelles/5624065-entre-ciel-et-mer.html',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'url': 'http://www.rts.ch/emissions/passe-moi-les-jumelles/5624067-entre-ciel-et-mer.html',
|
||||||
|
'only_matching': True,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
m = self._match_valid_url(url)
|
webpage, urlh = self._download_webpage_handle(url, self._match_id(url))
|
||||||
media_id = m.group('rts_id') or m.group('id')
|
if urlh.url != url:
|
||||||
display_id = m.group('display_id') or media_id
|
return self.url_result(urlh.url)
|
||||||
|
|
||||||
def download_json(internal_id):
|
mobj = self._match_valid_url(url)
|
||||||
return self._download_json(
|
display_id = traverse_obj(mobj, 'display_id', default=mobj.group('id')) or mobj.group('id')
|
||||||
f'http://www.rts.ch/a/{internal_id}.html?f=json/article',
|
|
||||||
display_id)
|
|
||||||
|
|
||||||
all_info = download_json(media_id)
|
media_list = []
|
||||||
|
article_details = self._search_json(r'articleDetails\s*=\s*', webpage, 'article details', display_id)
|
||||||
|
traverse_obj(article_details, ('mainMedia', {lambda x: media_list.append(x) if x else None}))
|
||||||
|
traverse_obj(article_details, ('innerMediaElements', {lambda x: media_list.extend(x)}))
|
||||||
|
traverse_obj(article_details, ('mediaElements', {lambda x: media_list.extend(x)}))
|
||||||
|
media_list = orderedSet(media_list)
|
||||||
|
|
||||||
# media_id extracted out of URL is not always a real id
|
|
||||||
if 'video' not in all_info and 'audio' not in all_info:
|
|
||||||
entries = []
|
entries = []
|
||||||
|
for media in media_list:
|
||||||
|
media_id = media['oid']
|
||||||
|
media_info = self._get_media_data('rts', media['type'], media_id)
|
||||||
|
|
||||||
for item in all_info.get('items', []):
|
if fmts := self._extract_formats(media_info, media_id):
|
||||||
item_url = item.get('url')
|
entries.append({
|
||||||
if not item_url:
|
'id': media_info['id'],
|
||||||
continue
|
'title': media_info['title'],
|
||||||
entries.append(self.url_result(item_url, 'RTS'))
|
'formats': fmts,
|
||||||
|
'description': media_info.get('description'),
|
||||||
|
'thumbnails': [traverse_obj(media_info, ('imageUrl', {lambda x: {
|
||||||
|
'url': x,
|
||||||
|
**parse_resolution(x),
|
||||||
|
}}))],
|
||||||
|
'timestamp': parse_iso8601(media_info.get('date')),
|
||||||
|
'duration': traverse_obj(media_info, ('duration', {functools.partial(int_or_none, scale=1000)})),
|
||||||
|
'categories': [media.get('category')],
|
||||||
|
})
|
||||||
|
|
||||||
if not entries:
|
return self.playlist_result(
|
||||||
page, urlh = self._download_webpage_handle(url, display_id)
|
entries, article_details.get('oid'), article_details.get('title'),
|
||||||
if re.match(self._VALID_URL, urlh.url).group('id') != media_id:
|
article_details.get('lead'), display_id=display_id,
|
||||||
return self.url_result(urlh.url, 'RTS')
|
tags=traverse_obj(article_details, ('tags', ..., 'name')))
|
||||||
|
|
||||||
# article with videos on rhs
|
|
||||||
videos = re.findall(
|
|
||||||
r'<article[^>]+class="content-item"[^>]*>\s*<a[^>]+data-video-urn="urn:([^"]+)"',
|
|
||||||
page)
|
|
||||||
if not videos:
|
|
||||||
videos = re.findall(
|
|
||||||
r'(?s)<iframe[^>]+class="srg-player"[^>]+src="[^"]+urn:([^"]+)"',
|
|
||||||
page)
|
|
||||||
if videos:
|
|
||||||
entries = [self.url_result(f'srgssr:{video_urn}', 'SRGSSR') for video_urn in videos]
|
|
||||||
|
|
||||||
if entries:
|
|
||||||
return self.playlist_result(entries, media_id, all_info.get('title'))
|
|
||||||
|
|
||||||
internal_id = self._html_search_regex(
|
|
||||||
r'<(?:video|audio) data-id="([0-9]+)"', page,
|
|
||||||
'internal video id')
|
|
||||||
all_info = download_json(internal_id)
|
|
||||||
|
|
||||||
media_type = 'video' if 'video' in all_info else 'audio'
|
|
||||||
|
|
||||||
# check for errors
|
|
||||||
self._get_media_data('rts', media_type, media_id)
|
|
||||||
|
|
||||||
info = all_info['video']['JSONinfo'] if 'video' in all_info else all_info['audio']
|
|
||||||
|
|
||||||
title = info['title']
|
|
||||||
|
|
||||||
|
def _extract_formats(self, media_info, media_id):
|
||||||
def extract_bitrate(url):
|
def extract_bitrate(url):
|
||||||
return int_or_none(self._search_regex(
|
return int_or_none(self._search_regex(
|
||||||
r'-([0-9]+)k\.', url, 'bitrate', default=None))
|
r'-([0-9]+)k\.', url, 'bitrate', default=None))
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
streams = info.get('streams', {})
|
for idx, stream in enumerate(traverse_obj(
|
||||||
for format_id, format_url in streams.items():
|
media_info, ('resourceList', lambda _, v: v['url']))):
|
||||||
if format_id == 'hds_sd' and 'hds' in streams:
|
format_id = stream.get('protocol') or str(idx)
|
||||||
|
format_url = stream['url']
|
||||||
|
if format_id == 'hds_sd' and 'hds' in stream:
|
||||||
continue
|
continue
|
||||||
if format_id == 'hls_sd' and 'hls' in streams:
|
if format_id == 'hls_sd' and 'hls' in stream:
|
||||||
continue
|
continue
|
||||||
ext = determine_ext(format_url)
|
ext = determine_ext(format_url)
|
||||||
if ext in ('m3u8', 'f4m'):
|
if ext in ('m3u8', 'f4m'):
|
||||||
|
@ -195,37 +303,5 @@ class RTSIE(SRGSSRIE): # XXX: Do not subclass from concrete IE
|
||||||
'tbr': extract_bitrate(format_url),
|
'tbr': extract_bitrate(format_url),
|
||||||
})
|
})
|
||||||
|
|
||||||
download_base = 'http://rtsww{}-d.rts.ch/'.format('-a' if media_type == 'audio' else '')
|
|
||||||
for media in info.get('media', []):
|
|
||||||
media_url = media.get('url')
|
|
||||||
if not media_url or re.match(r'https?://', media_url):
|
|
||||||
continue
|
|
||||||
rate = media.get('rate')
|
|
||||||
ext = media.get('ext') or determine_ext(media_url, 'mp4')
|
|
||||||
format_id = ext
|
|
||||||
if rate:
|
|
||||||
format_id += '-%dk' % rate
|
|
||||||
formats.append({
|
|
||||||
'format_id': format_id,
|
|
||||||
'url': urljoin(download_base, media_url),
|
|
||||||
'tbr': rate or extract_bitrate(media_url),
|
|
||||||
})
|
|
||||||
|
|
||||||
self._check_formats(formats, media_id)
|
self._check_formats(formats, media_id)
|
||||||
|
return formats
|
||||||
duration = info.get('duration') or info.get('cutout') or info.get('cutduration')
|
|
||||||
if isinstance(duration, str):
|
|
||||||
duration = parse_duration(duration)
|
|
||||||
|
|
||||||
return {
|
|
||||||
'id': media_id,
|
|
||||||
'display_id': display_id,
|
|
||||||
'formats': formats,
|
|
||||||
'title': title,
|
|
||||||
'description': info.get('intro'),
|
|
||||||
'duration': duration,
|
|
||||||
'view_count': int_or_none(info.get('plays')),
|
|
||||||
'uploader': info.get('programName'),
|
|
||||||
'timestamp': parse_iso8601(info.get('broadcast_date')),
|
|
||||||
'thumbnail': unescapeHTML(info.get('preview_image_url')),
|
|
||||||
}
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class SRGSSRIE(InfoExtractor):
|
||||||
def _get_media_data(self, bu, media_type, media_id):
|
def _get_media_data(self, bu, media_type, media_id):
|
||||||
query = {'onlyChapters': True} if media_type == 'video' else {}
|
query = {'onlyChapters': True} if media_type == 'video' else {}
|
||||||
full_media_data = self._download_json(
|
full_media_data = self._download_json(
|
||||||
f'https://il.srgssr.ch/integrationlayer/2.0/{bu}/mediaComposition/{media_type}/{media_id}.json',
|
f'https://il.srgssr.ch/integrationlayer/2.0/mediaComposition/byUrn/urn:{bu}:{media_type}:{media_id}.json',
|
||||||
media_id, query=query)['chapterList']
|
media_id, query=query)['chapterList']
|
||||||
try:
|
try:
|
||||||
media_data = next(
|
media_data = next(
|
||||||
|
@ -165,7 +165,7 @@ class SRGSSRPlayIE(InfoExtractor):
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.srf.ch/play/tv/10vor10/video/snowden-beantragt-asyl-in-russland?id=28e1a57d-5b76-4399-8ab3-9097f071e6c5',
|
'url': 'http://www.srf.ch/play/tv/10vor10/video/snowden-beantragt-asyl-in-russland?id=28e1a57d-5b76-4399-8ab3-9097f071e6c5',
|
||||||
'md5': '6db2226ba97f62ad42ce09783680046c',
|
'md5': '81c6ad90d774c46e3c54ea2f01a94db3',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '28e1a57d-5b76-4399-8ab3-9097f071e6c5',
|
'id': '28e1a57d-5b76-4399-8ab3-9097f071e6c5',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
|
@ -173,7 +173,7 @@ class SRGSSRPlayIE(InfoExtractor):
|
||||||
'title': 'Snowden beantragt Asyl in Russland',
|
'title': 'Snowden beantragt Asyl in Russland',
|
||||||
'timestamp': 1372708215,
|
'timestamp': 1372708215,
|
||||||
'duration': 113.827,
|
'duration': 113.827,
|
||||||
'thumbnail': r're:^https?://.*1383719781\.png$',
|
'thumbnail': r're:^https?://download-media\.srf\.ch/.*\.(?:png|jpg)$',
|
||||||
},
|
},
|
||||||
'expected_warnings': ['Unable to download f4m manifest'],
|
'expected_warnings': ['Unable to download f4m manifest'],
|
||||||
}, {
|
}, {
|
||||||
|
@ -185,6 +185,7 @@ class SRGSSRPlayIE(InfoExtractor):
|
||||||
'title': 'Saira: Tujetsch - tuttina cuntinuar cun Sedrun Mustér Turissem',
|
'title': 'Saira: Tujetsch - tuttina cuntinuar cun Sedrun Mustér Turissem',
|
||||||
'timestamp': 1444709160,
|
'timestamp': 1444709160,
|
||||||
'duration': 336.816,
|
'duration': 336.816,
|
||||||
|
'thumbnail': r're:^https?://download-media\.srf\.ch/.*\.(?:png|jpg)$',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
# rtmp download
|
# rtmp download
|
||||||
|
@ -217,7 +218,7 @@ class SRGSSRPlayIE(InfoExtractor):
|
||||||
'duration': 94.0,
|
'duration': 94.0,
|
||||||
'upload_date': '20170215',
|
'upload_date': '20170215',
|
||||||
'timestamp': 1487173560,
|
'timestamp': 1487173560,
|
||||||
'thumbnail': r're:https?://www\.swissinfo\.ch/srgscalableimage/42961964',
|
'thumbnail': r're:https?://cdn\.prod\.swi-services\.ch/.+',
|
||||||
'subtitles': 'count:9',
|
'subtitles': 'count:9',
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user