mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-04-27 19:15:53 +00:00
Compare commits
5 Commits
485de69dbf
...
30302df22b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30302df22b | ||
|
|
3e609b2ced | ||
|
|
d399505fdf | ||
|
|
61d4cd0bc0 | ||
|
|
4385480795 |
@ -1373,6 +1373,7 @@ class TestUtil(unittest.TestCase):
|
||||
self.assertEqual(parse_resolution('pre_1920x1080_post'), {'width': 1920, 'height': 1080})
|
||||
self.assertEqual(parse_resolution('ep1x2'), {})
|
||||
self.assertEqual(parse_resolution('1920, 1080'), {'width': 1920, 'height': 1080})
|
||||
self.assertEqual(parse_resolution('1920w', lenient=True), {'width': 1920})
|
||||
|
||||
def test_parse_bitrate(self):
|
||||
self.assertEqual(parse_bitrate(None), None)
|
||||
|
||||
@ -572,7 +572,21 @@ class FFmpegFD(ExternalFD):
|
||||
if end_time:
|
||||
args += ['-t', str(end_time - start_time)]
|
||||
|
||||
args += [*self._configuration_args((f'_i{i + 1}', '_i')), '-i', fmt['url']]
|
||||
url = fmt['url']
|
||||
if self.params.get('enable_file_urls') and url.startswith('file:'):
|
||||
# The default protocol_whitelist is 'file,crypto,data' when reading local m3u8 URLs,
|
||||
# so only local segments can be read unless we also include 'http,https,tcp,tls'
|
||||
args += ['-protocol_whitelist', 'file,crypto,data,http,https,tcp,tls']
|
||||
# ffmpeg incorrectly handles 'file:' URLs by only removing the
|
||||
# 'file:' prefix and treating the rest as if it's a normal filepath.
|
||||
# FFmpegPostProcessor also depends on this behavior, so we need to fixup the URLs:
|
||||
# - On Windows/Cygwin, replace 'file:///' and 'file://localhost/' with 'file:'
|
||||
# - On *nix, replace 'file://localhost/' with 'file:/'
|
||||
# Ref: https://github.com/yt-dlp/yt-dlp/issues/13781
|
||||
# https://trac.ffmpeg.org/ticket/2702
|
||||
url = re.sub(r'^file://(?:localhost)?/', 'file:' if os.name == 'nt' else 'file:/', url)
|
||||
|
||||
args += [*self._configuration_args((f'_i{i + 1}', '_i')), '-i', url]
|
||||
|
||||
if not (start_time or end_time) or not self.params.get('force_keyframes_at_cuts'):
|
||||
args += ['-c', 'copy']
|
||||
|
||||
@ -640,6 +640,7 @@ from .fancode import (
|
||||
FancodeVodIE,
|
||||
)
|
||||
from .fathom import FathomIE
|
||||
from .faulio import FaulioLiveIE
|
||||
from .faz import FazIE
|
||||
from .fc2 import (
|
||||
FC2IE,
|
||||
@ -1568,6 +1569,7 @@ from .pluralsight import (
|
||||
)
|
||||
from .plutotv import PlutoTVIE
|
||||
from .plvideo import PlVideoIE
|
||||
from .plyr import PlyrEmbedIE
|
||||
from .podbayfm import (
|
||||
PodbayFMChannelIE,
|
||||
PodbayFMIE,
|
||||
|
||||
92
yt_dlp/extractor/faulio.py
Normal file
92
yt_dlp/extractor/faulio.py
Normal file
@ -0,0 +1,92 @@
|
||||
import re
|
||||
import urllib.parse
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import js_to_json, url_or_none
|
||||
from ..utils.traversal import traverse_obj
|
||||
|
||||
|
||||
class FaulioLiveIE(InfoExtractor):
|
||||
_DOMAINS = (
|
||||
'aloula.sba.sa',
|
||||
'maraya.sba.net.ae',
|
||||
'sat7plus.org',
|
||||
)
|
||||
_VALID_URL = fr'https?://(?:{"|".join(map(re.escape, _DOMAINS))})/(?:(?:en|ar|fa)/)?live/(?P<id>[a-zA-Z0-9-]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://aloula.sba.sa/live/saudiatv',
|
||||
'info_dict': {
|
||||
'id': 'aloula.faulio.com_saudiatv',
|
||||
'title': str,
|
||||
'description': str,
|
||||
'ext': 'mp4',
|
||||
'live_status': 'is_live',
|
||||
},
|
||||
'params': {
|
||||
'skip_download': 'Livestream',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://maraya.sba.net.ae/live/1',
|
||||
'info_dict': {
|
||||
'id': 'maraya.faulio.com_1',
|
||||
'title': str,
|
||||
'description': str,
|
||||
'ext': 'mp4',
|
||||
'live_status': 'is_live',
|
||||
},
|
||||
'params': {
|
||||
'skip_download': 'Livestream',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://sat7plus.org/live/pars',
|
||||
'info_dict': {
|
||||
'id': 'sat7.faulio.com_pars',
|
||||
'title': str,
|
||||
'description': str,
|
||||
'ext': 'mp4',
|
||||
'live_status': 'is_live',
|
||||
},
|
||||
'params': {
|
||||
'skip_download': 'Livestream',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://sat7plus.org/fa/live/arabic',
|
||||
'only_matching': True,
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, video_id)
|
||||
|
||||
config_data = self._search_json(
|
||||
r'window\.__NUXT__\.config=', webpage, 'config', video_id, transform_source=js_to_json)
|
||||
api_base = config_data['public']['TRANSLATIONS_API_URL']
|
||||
|
||||
channel = traverse_obj(
|
||||
self._download_json(f'{api_base}/channels', video_id),
|
||||
(lambda k, v: v['url'] == video_id, any))
|
||||
|
||||
formats = []
|
||||
subtitles = {}
|
||||
if hls_url := traverse_obj(channel, ('streams', 'hls', {url_or_none})):
|
||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||
hls_url, video_id, 'mp4', m3u8_id='hls', live=True, fatal=False)
|
||||
formats.extend(fmts)
|
||||
self._merge_subtitles(subs, target=subtitles)
|
||||
|
||||
if mpd_url := traverse_obj(channel, ('streams', 'mpd', {url_or_none})):
|
||||
fmts, subs = self._extract_mpd_formats_and_subtitles(
|
||||
mpd_url, video_id, mpd_id='dash', fatal=False)
|
||||
formats.extend(fmts)
|
||||
self._merge_subtitles(subs, target=subtitles)
|
||||
|
||||
return {
|
||||
'id': f'{urllib.parse.urlparse(api_base).hostname}_{video_id}',
|
||||
**traverse_obj(channel, {
|
||||
'title': ('title', {str}),
|
||||
'description': ('description', {str}),
|
||||
}),
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
'is_live': True,
|
||||
}
|
||||
104
yt_dlp/extractor/plyr.py
Normal file
104
yt_dlp/extractor/plyr.py
Normal file
@ -0,0 +1,104 @@
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from .vimeo import VimeoIE
|
||||
|
||||
|
||||
class PlyrEmbedIE(InfoExtractor):
|
||||
_VALID_URL = False
|
||||
_WEBPAGE_TESTS = [{
|
||||
# data-plyr-embed-id="https://player.vimeo.com/video/522319456/90e5c96063?dnt=1"
|
||||
'url': 'https://www.dhm.de/zeughauskino/filmreihen/online-filmreihen/filme-des-marshall-plans/200000000-mouths/',
|
||||
'info_dict': {
|
||||
'id': '522319456',
|
||||
'ext': 'mp4',
|
||||
'title': '200.000.000 Mouths (1950–51)',
|
||||
'uploader': 'Zeughauskino',
|
||||
'uploader_url': '',
|
||||
'comment_count': int,
|
||||
'like_count': int,
|
||||
'duration': 963,
|
||||
'thumbnail': 'https://i.vimeocdn.com/video/1081797161-9f09ddb4b7faa86e834e006b8e4b9c2cbaa0baa7da493211bf0796ae133a5ab8-d',
|
||||
'timestamp': 1615467405,
|
||||
'upload_date': '20210311',
|
||||
'release_timestamp': 1615467405,
|
||||
'release_date': '20210311',
|
||||
},
|
||||
'params': {'skip_download': 'm3u8'},
|
||||
'expected_warnings': ['Failed to parse XML: not well-formed'],
|
||||
}, {
|
||||
# data-plyr-provider="vimeo" data-plyr-embed-id="803435276"
|
||||
'url': 'https://www.inarcassa.it/',
|
||||
'info_dict': {
|
||||
'id': '803435276',
|
||||
'ext': 'mp4',
|
||||
'title': 'HOME_Moto_Perpetuo',
|
||||
'uploader': 'Inarcassa',
|
||||
'uploader_url': '',
|
||||
'duration': 38,
|
||||
'thumbnail': 'https://i.vimeocdn.com/video/1663734769-945ad7ffabb16dbca009c023fd1d7b36bdb426a3dbae8345ed758136fe28f89a-d',
|
||||
},
|
||||
'params': {'skip_download': 'm3u8'},
|
||||
'expected_warnings': ['Failed to parse XML: not well-formed'],
|
||||
}, {
|
||||
# data-plyr-embed-id="https://youtu.be/GF-BjYKoAqI"
|
||||
'url': 'https://www.profile.nl',
|
||||
'info_dict': {
|
||||
'id': 'GF-BjYKoAqI',
|
||||
'ext': 'mp4',
|
||||
'title': 'PROFILE: Recruitment Profile',
|
||||
'description': '',
|
||||
'media_type': 'video',
|
||||
'uploader': 'Profile Nederland',
|
||||
'uploader_id': '@profilenederland',
|
||||
'uploader_url': 'https://www.youtube.com/@profilenederland',
|
||||
'channel': 'Profile Nederland',
|
||||
'channel_id': 'UC9AUkB0Tv39-TBYjs05n3vg',
|
||||
'channel_url': 'https://www.youtube.com/channel/UC9AUkB0Tv39-TBYjs05n3vg',
|
||||
'channel_follower_count': int,
|
||||
'view_count': int,
|
||||
'like_count': int,
|
||||
'age_limit': 0,
|
||||
'duration': 39,
|
||||
'thumbnail': 'https://i.ytimg.com/vi/GF-BjYKoAqI/maxresdefault.jpg',
|
||||
'categories': ['Autos & Vehicles'],
|
||||
'tags': [],
|
||||
'timestamp': 1675692990,
|
||||
'upload_date': '20230206',
|
||||
'playable_in_embed': True,
|
||||
'availability': 'public',
|
||||
'live_status': 'not_live',
|
||||
},
|
||||
}, {
|
||||
# data-plyr-embed-id="B1TZV8rNZoc" data-plyr-provider="youtube"
|
||||
'url': 'https://www.vnis.edu.vn',
|
||||
'info_dict': {
|
||||
'id': 'vnis.edu',
|
||||
'title': 'VNIS Education - Master Agent các Trường hàng đầu Bắc Mỹ',
|
||||
'description': 'md5:4dafcf7335bb018780e4426da8ab8e4e',
|
||||
'age_limit': 0,
|
||||
'thumbnail': 'https://vnis.edu.vn/wp-content/uploads/2021/05/ve-welcome-en.png',
|
||||
'timestamp': 1753233356,
|
||||
'upload_date': '20250723',
|
||||
},
|
||||
'playlist_count': 3,
|
||||
}]
|
||||
|
||||
@classmethod
|
||||
def _extract_embed_urls(cls, url, webpage):
|
||||
plyr_embeds = re.finditer(r'''(?x)
|
||||
<div[^>]+(?:
|
||||
data-plyr-embed-id="(?P<id1>[^"]+)"[^>]+data-plyr-provider="(?P<provider1>[^"]+)"|
|
||||
data-plyr-provider="(?P<provider2>[^"]+)"[^>]+data-plyr-embed-id="(?P<id2>[^"]+)"
|
||||
)[^>]*>''', webpage)
|
||||
for mobj in plyr_embeds:
|
||||
embed_id = mobj.group('id1') or mobj.group('id2')
|
||||
provider = mobj.group('provider1') or mobj.group('provider2')
|
||||
if provider == 'vimeo':
|
||||
if not re.match(r'https?://', embed_id):
|
||||
embed_id = f'https://player.vimeo.com/video/{embed_id}'
|
||||
yield VimeoIE._smuggle_referrer(embed_id, url)
|
||||
elif provider == 'youtube':
|
||||
if not re.match(r'https?://', embed_id):
|
||||
embed_id = f'https://youtube.com/watch?v={embed_id}'
|
||||
yield embed_id
|
||||
@ -8,84 +8,9 @@ from ..utils import (
|
||||
|
||||
|
||||
class SportDeutschlandIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://sportdeutschland\.tv/(?P<id>(?:[^/]+/)?[^?#/&]+)'
|
||||
_VALID_URL = r'https?://(?:player\.)?sportdeutschland\.tv/(?P<id>(?:[^/?#]+/)?[^?#/&]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://sportdeutschland.tv/blauweissbuchholztanzsport/buchholzer-formationswochenende-2023-samstag-1-bundesliga-landesliga',
|
||||
'info_dict': {
|
||||
'id': '9839a5c7-0dbb-48a8-ab63-3b408adc7b54',
|
||||
'ext': 'mp4',
|
||||
'title': 'Buchholzer Formationswochenende 2023 - Samstag - 1. Bundesliga / Landesliga',
|
||||
'display_id': 'blauweissbuchholztanzsport/buchholzer-formationswochenende-2023-samstag-1-bundesliga-landesliga',
|
||||
'description': 'md5:a288c794a5ee69e200d8f12982f81a87',
|
||||
'live_status': 'was_live',
|
||||
'channel': 'Blau-Weiss Buchholz Tanzsport',
|
||||
'channel_url': 'https://sportdeutschland.tv/blauweissbuchholztanzsport',
|
||||
'channel_id': '93ec33c9-48be-43b6-b404-e016b64fdfa3',
|
||||
'duration': 32447,
|
||||
'upload_date': '20230114',
|
||||
'timestamp': 1673733618,
|
||||
},
|
||||
'skip': 'not found',
|
||||
}, {
|
||||
'url': 'https://sportdeutschland.tv/deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0',
|
||||
'info_dict': {
|
||||
'id': '95c80c52-6b9a-4ae9-9197-984145adfced',
|
||||
'ext': 'mp4',
|
||||
'title': 'BWF Tour: 1. Runde Feld 1 - YONEX GAINWARD German Open 2022',
|
||||
'display_id': 'deutscherbadmintonverband/bwf-tour-1-runde-feld-1-yonex-gainward-german-open-2022-0',
|
||||
'description': 'md5:2afb5996ceb9ac0b2ac81f563d3a883e',
|
||||
'live_status': 'was_live',
|
||||
'channel': 'Deutscher Badminton Verband',
|
||||
'channel_url': 'https://sportdeutschland.tv/deutscherbadmintonverband',
|
||||
'channel_id': '93ca5866-2551-49fc-8424-6db35af58920',
|
||||
'duration': 41097,
|
||||
'upload_date': '20220309',
|
||||
'timestamp': 1646860727.0,
|
||||
},
|
||||
'skip': 'not found',
|
||||
}, {
|
||||
'url': 'https://sportdeutschland.tv/ggcbremen/formationswochenende-latein-2023',
|
||||
'info_dict': {
|
||||
'id': '9889785e-55b0-4d97-a72a-ce9a9f157cce',
|
||||
'title': 'Formationswochenende Latein 2023 - Samstag',
|
||||
'display_id': 'ggcbremen/formationswochenende-latein-2023',
|
||||
'description': 'md5:6e4060d40ff6a8f8eeb471b51a8f08b2',
|
||||
'live_status': 'was_live',
|
||||
'channel': 'Grün-Gold-Club Bremen e.V.',
|
||||
'channel_id': '9888f04e-bb46-4c7f-be47-df960a4167bb',
|
||||
'channel_url': 'https://sportdeutschland.tv/ggcbremen',
|
||||
},
|
||||
'playlist_count': 3,
|
||||
'playlist': [{
|
||||
'info_dict': {
|
||||
'id': '988e1fea-9d44-4fab-8c72-3085fb667547',
|
||||
'ext': 'mp4',
|
||||
'channel_url': 'https://sportdeutschland.tv/ggcbremen',
|
||||
'channel_id': '9888f04e-bb46-4c7f-be47-df960a4167bb',
|
||||
'channel': 'Grün-Gold-Club Bremen e.V.',
|
||||
'duration': 86,
|
||||
'title': 'Formationswochenende Latein 2023 - Samstag Part 1',
|
||||
'upload_date': '20230225',
|
||||
'timestamp': 1677349909,
|
||||
'live_status': 'was_live',
|
||||
},
|
||||
}],
|
||||
'skip': 'not found',
|
||||
}, {
|
||||
'url': 'https://sportdeutschland.tv/dtb/gymnastik-international-tag-1',
|
||||
'info_dict': {
|
||||
'id': '95d71b8a-370a-4b87-ad16-94680da18528',
|
||||
'ext': 'mp4',
|
||||
'title': r're:Gymnastik International - Tag 1 .+',
|
||||
'display_id': 'dtb/gymnastik-international-tag-1',
|
||||
'channel_id': '936ecef1-2f4a-4e08-be2f-68073cb7ecab',
|
||||
'channel': 'Deutscher Turner-Bund',
|
||||
'channel_url': 'https://sportdeutschland.tv/dtb',
|
||||
'description': 'md5:07a885dde5838a6f0796ee21dc3b0c52',
|
||||
'live_status': 'is_live',
|
||||
},
|
||||
'skip': 'live',
|
||||
}, {
|
||||
# Single-part video, direct link
|
||||
'url': 'https://sportdeutschland.tv/rostock-griffins/gfl2-rostock-griffins-vs-elmshorn-fighting-pirates',
|
||||
'md5': '35c11a19395c938cdd076b93bda54cde',
|
||||
'info_dict': {
|
||||
@ -100,7 +25,82 @@ class SportDeutschlandIE(InfoExtractor):
|
||||
'channel_id': '9635f21c-3f67-4584-9ce4-796e9a47276b',
|
||||
'timestamp': 1749913117,
|
||||
'upload_date': '20250614',
|
||||
'duration': 12287.0,
|
||||
},
|
||||
}, {
|
||||
# Single-part video, embedded player link
|
||||
'url': 'https://player.sportdeutschland.tv/9e9619c4-7d77-43c4-926d-49fb57dc06dc',
|
||||
'info_dict': {
|
||||
'id': '9f27a97d-1544-4d0b-aa03-48d92d17a03a',
|
||||
'ext': 'mp4',
|
||||
'title': 'GFL2: Rostock Griffins vs. Elmshorn Fighting Pirates',
|
||||
'display_id': '9e9619c4-7d77-43c4-926d-49fb57dc06dc',
|
||||
'channel': 'Rostock Griffins',
|
||||
'channel_url': 'https://sportdeutschland.tv/rostock-griffins',
|
||||
'live_status': 'was_live',
|
||||
'description': 'md5:60cb00067e55dafa27b0933a43d72862',
|
||||
'channel_id': '9635f21c-3f67-4584-9ce4-796e9a47276b',
|
||||
'timestamp': 1749913117,
|
||||
'upload_date': '20250614',
|
||||
'duration': 12287.0,
|
||||
},
|
||||
'params': {'skip_download': True},
|
||||
}, {
|
||||
# Multi-part video
|
||||
'url': 'https://sportdeutschland.tv/rhine-ruhr-2025-fisu-world-university-games/volleyball-w-japan-vs-brasilien-halbfinale-2',
|
||||
'info_dict': {
|
||||
'id': '9f63d737-2444-4e3a-a1ea-840df73fd481',
|
||||
'display_id': 'rhine-ruhr-2025-fisu-world-university-games/volleyball-w-japan-vs-brasilien-halbfinale-2',
|
||||
'title': 'Volleyball w: Japan vs. Braslien - Halbfinale 2',
|
||||
'description': 'md5:0a17da15e48a687e6019639c3452572b',
|
||||
'channel': 'Rhine-Ruhr 2025 FISU World University Games',
|
||||
'channel_id': '9f5216be-a49d-470b-9a30-4fe9df993334',
|
||||
'channel_url': 'https://sportdeutschland.tv/rhine-ruhr-2025-fisu-world-university-games',
|
||||
'live_status': 'was_live',
|
||||
},
|
||||
'playlist_count': 2,
|
||||
'playlist': [{
|
||||
'info_dict': {
|
||||
'id': '9f725a94-d43e-40ff-859d-13da3081bb04',
|
||||
'ext': 'mp4',
|
||||
'title': 'Volleyball w: Japan vs. Braslien - Halbfinale 2 Part 1',
|
||||
'channel': 'Rhine-Ruhr 2025 FISU World University Games',
|
||||
'channel_id': '9f5216be-a49d-470b-9a30-4fe9df993334',
|
||||
'channel_url': 'https://sportdeutschland.tv/rhine-ruhr-2025-fisu-world-university-games',
|
||||
'duration': 14773.0,
|
||||
'timestamp': 1753085197,
|
||||
'upload_date': '20250721',
|
||||
'live_status': 'was_live',
|
||||
},
|
||||
}, {
|
||||
'info_dict': {
|
||||
'id': '9f725a94-370e-4477-89ac-1751098e3217',
|
||||
'ext': 'mp4',
|
||||
'title': 'Volleyball w: Japan vs. Braslien - Halbfinale 2 Part 2',
|
||||
'channel': 'Rhine-Ruhr 2025 FISU World University Games',
|
||||
'channel_id': '9f5216be-a49d-470b-9a30-4fe9df993334',
|
||||
'channel_url': 'https://sportdeutschland.tv/rhine-ruhr-2025-fisu-world-university-games',
|
||||
'duration': 14773.0,
|
||||
'timestamp': 1753128421,
|
||||
'upload_date': '20250721',
|
||||
'live_status': 'was_live',
|
||||
},
|
||||
}],
|
||||
}, {
|
||||
# Livestream
|
||||
'url': 'https://sportdeutschland.tv/dtb/gymnastik-international-tag-1',
|
||||
'info_dict': {
|
||||
'id': '95d71b8a-370a-4b87-ad16-94680da18528',
|
||||
'ext': 'mp4',
|
||||
'title': r're:Gymnastik International - Tag 1 .+',
|
||||
'display_id': 'dtb/gymnastik-international-tag-1',
|
||||
'channel_id': '936ecef1-2f4a-4e08-be2f-68073cb7ecab',
|
||||
'channel': 'Deutscher Turner-Bund',
|
||||
'channel_url': 'https://sportdeutschland.tv/dtb',
|
||||
'description': 'md5:07a885dde5838a6f0796ee21dc3b0c52',
|
||||
'live_status': 'is_live',
|
||||
},
|
||||
'skip': 'live',
|
||||
}]
|
||||
|
||||
def _process_video(self, asset_id, video):
|
||||
|
||||
@ -1875,6 +1875,11 @@ def parse_resolution(s, *, lenient=False):
|
||||
if mobj:
|
||||
return {'height': int(mobj.group(1)) * 540}
|
||||
|
||||
if lenient:
|
||||
mobj = re.search(r'(?<!\d)(\d{2,5})w(?![a-zA-Z0-9])', s)
|
||||
if mobj:
|
||||
return {'width': int(mobj.group(1))}
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user