From 5d96527be80dc1ed1702d9cd548ff86de570ad70 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Fri, 6 Jun 2025 16:53:30 -0500 Subject: [PATCH] [ie/stacommu] Avoid partial stream formats (#13412) Authored by: bashonly --- yt_dlp/extractor/stacommu.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/stacommu.py b/yt_dlp/extractor/stacommu.py index 830018518..e6866f151 100644 --- a/yt_dlp/extractor/stacommu.py +++ b/yt_dlp/extractor/stacommu.py @@ -4,6 +4,7 @@ from .wrestleuniverse import WrestleUniverseBaseIE from ..utils import ( int_or_none, traverse_obj, + url_basename, url_or_none, ) @@ -65,9 +66,19 @@ class StacommuBaseIE(WrestleUniverseBaseIE): hls_info, decrypt = self._call_encrypted_api( video_id, ':watchArchive', 'stream information', data={'method': 1}) + formats = self._get_formats(hls_info, ('hls', 'urls', ..., {url_or_none}), video_id) + for f in formats: + # bitrates are exaggerated in PPV playlists, so avoid wrong/huge filesize_approx values + if f.get('tbr'): + f['tbr'] = int(f['tbr'] / 2.5) + # prefer variants with the same basename as the master playlist to avoid partial streams + f['format_id'] = url_basename(f['url']).partition('.')[0] + if not f['format_id'].startswith(url_basename(f['manifest_url']).partition('.')[0]): + f['preference'] = -10 + return { 'id': video_id, - 'formats': self._get_formats(hls_info, ('hls', 'urls', ..., {url_or_none}), video_id), + 'formats': formats, 'hls_aes': self._extract_hls_key(hls_info, 'hls', decrypt), **traverse_obj(video_info, { 'title': ('displayName', {str}),