fix HLS stream warning by disabling native downloader and retrying with ffmpeg

- Set hls_prefer_native: False to skip yt-dlp's native HLS downloader which emits
  'Live HLS streams are not supported' warning
- Add retry logic that catches HLS-related exceptions and retries with
  downloader=ffmpeg and hls_use_mpegts=True
This commit is contained in:
2026-05-29 18:53:47 +02:00
parent 765e43c684
commit 38c12638a4

View File

@@ -550,8 +550,10 @@ class AniworldLoader(Loader):
'nocheckcertificate': True, 'nocheckcertificate': True,
'logger': logger, 'logger': logger,
'progress_hooks': [events_progress_hook], 'progress_hooks': [events_progress_hook],
'downloader': 'ffmpeg', # yt-dlp defaults to native HLS downloader which warns about
'hls_use_mpegts': True, # "Live HLS streams are not supported" - disable to go
# straight to ffmpeg, avoiding the warning
'hls_prefer_native': False,
} }
if header: if header:
@@ -597,6 +599,40 @@ class AniworldLoader(Loader):
_cleanup_temp_file(temp_path) _cleanup_temp_file(temp_path)
continue continue
except Exception as exc: except Exception as exc:
# Check if this is an HLS-related failure that might succeed
# with additional ffmpeg options
exc_str = str(exc).lower()
is_hls_related = (
'hls' in exc_str or
'live' in exc_str or
'native downloader' in exc_str
)
if is_hls_related and 'ffmpeg' not in str(ydl_opts.get('downloader', '')):
logger.info(
"HLS stream detected, retrying with ffmpeg options: %s",
output_file
)
# Retry with ffmpeg explicitly set
retry_opts = ydl_opts.copy()
retry_opts['downloader'] = 'ffmpeg'
retry_opts['hls_use_mpegts'] = True
try:
with YoutubeDL(retry_opts) as ydl:
info = ydl.extract_info(link, download=True)
if os.path.exists(temp_path):
shutil.copyfile(temp_path, output_path)
os.remove(temp_path)
logger.info(
"Download completed successfully (retry): %s",
output_file
)
self.clear_cache()
return True
except Exception:
_cleanup_temp_file(temp_path)
# Continue to next provider if retry also fails
continue
logger.error( logger.error(
"YoutubeDL download failed with provider %s: %s: %s", "YoutubeDL download failed with provider %s: %s: %s",
provider_name, type(exc).__name__, exc provider_name, type(exc).__name__, exc