From 1316cbf7c1bf57660940f385f245e4118869fc93 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Mon, 10 Nov 2025 16:42:19 +0300 Subject: [PATCH 1/3] [FIX] strip out comment lines when creating yt-dlp command --- app/library/YTDLPOpts.py | 6 ++- app/tests/test_ytdlpopts.py | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/app/library/YTDLPOpts.py b/app/library/YTDLPOpts.py index f5ccab41..7d5d323c 100644 --- a/app/library/YTDLPOpts.py +++ b/app/library/YTDLPOpts.py @@ -29,7 +29,11 @@ class ARGSMerger: if not args or not isinstance(args, str) or len(args) < 2: return self - _args: list[str] = shlex.split(args) + _args: list[str] = shlex.split( + # Filter out comment lines. + "\n".join([line for line in args.split("\n") if not line.lstrip().startswith("#")]) + ) + if len(_args) > 0: self.args.extend(_args) diff --git a/app/tests/test_ytdlpopts.py b/app/tests/test_ytdlpopts.py index 6abdcdbe..8cc7a35f 100644 --- a/app/tests/test_ytdlpopts.py +++ b/app/tests/test_ytdlpopts.py @@ -527,6 +527,80 @@ class TestARGSMerger: assert result is merger # Returns self for chaining assert merger.args == ["--format", "best"] + def test_add_filters_comment_lines(self): + """Test that comment lines (starting with #) are filtered out.""" + from app.library.YTDLPOpts import ARGSMerger + + merger = ARGSMerger() + cli_with_comments = """--format best +# This is a comment +--output test.mp4 +#Another comment without space +--no-playlist""" + + merger.add(cli_with_comments) + + # Comments should be filtered out + assert "#" not in merger.as_string() + assert "This is a comment" not in merger.as_string() + assert "Another comment" not in merger.as_string() + + # Valid options should remain + assert "--format" in merger.args + assert "best" in merger.args + assert "--output" in merger.args + assert "test.mp4" in merger.args + assert "--no-playlist" in merger.args + + def test_add_filters_indented_comment_lines(self): + """Test that indented comment lines are filtered out.""" + from app.library.YTDLPOpts import ARGSMerger + + merger = ARGSMerger() + cli_with_indented_comments = """--format best + # Indented comment with spaces + # Indented comment with tabs + --output test.mp4 + # Another indented comment +--socket-timeout 30""" + + merger.add(cli_with_indented_comments) + + # Comments should be filtered out + result = merger.as_string() + assert "# Indented comment with spaces" not in result + assert "# Indented comment with tabs" not in result + assert "# Another indented comment" not in result + + # Valid options should remain + assert "--format" in merger.args + assert "--output" in merger.args + assert "--socket-timeout" in merger.args + + def test_add_filters_complex_commented_extractor_args(self): + """Test filtering of complex real-world commented extractor-args.""" + from app.library.YTDLPOpts import ARGSMerger + + merger = ARGSMerger() + cli_with_complex_comments = """--extractor-args "youtube:player-client=default,tv,mweb,-web_safari;formats=incomplete" +#--extractor-args "youtube:player-client=default,tv,mweb;-formats=incomplete;player_js_version=actual" +#--extractor-args "youtube:player-client=default,tv,mweb,web_safari;formats=incomplete" +--socket-timeout 60""" + + merger.add(cli_with_complex_comments) + + result = merger.as_string() + + # Commented lines should be filtered out completely + assert "player_js_version=actual" not in result + # Check the specific commented variant (with comma before web_safari, not dash) + assert "mweb,web_safari;formats=incomplete" not in result + + # Valid extractor-args should remain (with -web_safari, note the dash) + assert "youtube:player-client=default,tv,mweb,-web_safari;formats=incomplete" in result + assert "--socket-timeout" in merger.args + assert "60" in merger.args + def test_add_multiple_args_with_chaining(self): """Test adding multiple arguments using method chaining.""" from app.library.YTDLPOpts import ARGSMerger From ddd7f7755131088205d6f0669766932574fad845 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Mon, 10 Nov 2025 16:43:13 +0300 Subject: [PATCH 2/3] [FIX] Show loading screen while waiting for modal text content. --- ui/app/components/GetInfo.vue | 3 +-- ui/app/components/ModalText.vue | 21 +++++++++++++-------- ui/app/layouts/default.vue | 11 ++++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ui/app/components/GetInfo.vue b/ui/app/components/GetInfo.vue index 67b9006f..9269f982 100644 --- a/ui/app/components/GetInfo.vue +++ b/ui/app/components/GetInfo.vue @@ -16,7 +16,7 @@ const props = defineProps<{ code_classes?: string }>() -const isLoading = ref(false) +const isLoading = ref(true) const data = ref({}) onMounted(async (): Promise => { @@ -35,7 +35,6 @@ onMounted(async (): Promise => { } try { - isLoading.value = true const response = await request(url) const body = await response.text() diff --git a/ui/app/components/ModalText.vue b/ui/app/components/ModalText.vue index 008981da..530095ec 100644 --- a/ui/app/components/ModalText.vue +++ b/ui/app/components/ModalText.vue @@ -31,14 +31,19 @@ code {