From 4f5ac8d8a0cdc8c0166d60f0d597d353365bd3b4 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Thu, 11 Jun 2026 17:51:30 +0300 Subject: [PATCH] fix: breaking change between yt-dlp 2026.03.17 -> 2026.06.09 due to CVE related to exec --- app/features/ytdlp/tests/test_ytdlp_module.py | 8 ++++++++ app/features/ytdlp/ytdlp.py | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/features/ytdlp/tests/test_ytdlp_module.py b/app/features/ytdlp/tests/test_ytdlp_module.py index 535de774..0e84c7df 100644 --- a/app/features/ytdlp/tests/test_ytdlp_module.py +++ b/app/features/ytdlp/tests/test_ytdlp_module.py @@ -349,6 +349,14 @@ class TestYTDLP: assert len(result) == 8 assert result.isalnum() + def test_exec_init(self) -> None: + YTDLP( + params={ + "compat_opts": set(), + "postprocessors": [{"key": "Exec", "exec_cmd": "echo %(title)q"}], + } + ) + def test_outtmpl_reuses_value(self) -> None: ytdlp = YTDLP(params={"outtmpl": {"default": "%(title)s"}}) diff --git a/app/features/ytdlp/ytdlp.py b/app/features/ytdlp/ytdlp.py index a04b3b08..43192bfb 100644 --- a/app/features/ytdlp/ytdlp.py +++ b/app/features/ytdlp/ytdlp.py @@ -81,6 +81,9 @@ class YTDLP(yt_dlp.YoutubeDL): except Exception: patched_params = params + self._ytptube_outtmpl_info: dict[str, Any] | None = None + self._ytptube_outtmpl_cache: dict[str, Any] = {} + super().__init__(params=patched_params, auto_init=auto_init) # Restore param and replace upstream archive set with our proxy @@ -90,8 +93,6 @@ class YTDLP(yt_dlp.YoutubeDL): except Exception: pass - self._ytptube_outtmpl_info: dict[str, Any] | None = None - self._ytptube_outtmpl_cache: dict[str, Any] = {} self.archive = _ArchiveProxy(orig_file) def _delete_downloaded_files(self, *args, **kwargs) -> None: @@ -105,14 +106,14 @@ class YTDLP(yt_dlp.YoutubeDL): self._ytptube_outtmpl_info = None self._ytptube_outtmpl_cache = {} - def prepare_outtmpl(self, outtmpl, info_dict, sanitize=False): + def prepare_outtmpl(self, outtmpl, info_dict, sanitize=False, *, _exec=False): if self._ytptube_outtmpl_info is not info_dict: self._ytptube_outtmpl_info = info_dict self._ytptube_outtmpl_cache = {} outtmpl, enriched = rewrite_outtmpl(outtmpl, info_dict, cache=self._ytptube_outtmpl_cache) - return super().prepare_outtmpl(outtmpl, enriched, sanitize=sanitize) + return super().prepare_outtmpl(outtmpl, enriched, sanitize=sanitize, _exec=_exec) def process_info(self, info_dict): try: