Skip to content

A feature-rich command-line audio/video downloader

[ie/stacommu] Avoid partial stream formats (#13412)

bashonly5d96527be80d
diff --git a/yt_dlp/extractor/stacommu.py b/yt_dlp/extractor/stacommu.py
index 8300185183..e6866f1517 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}),