From c004ec3b0befa8b9223ac3c9d22bf8692f78b7e3 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Wed, 2 Jul 2025 23:46:33 -0700 Subject: [PATCH] print emtpy functionality, do not use TP on soundcloud or bandcamp --- src/ytdl_sub/prebuilt_presets/music/albums_from_chapters.yaml | 3 ++- .../prebuilt_presets/music/albums_from_playlists.yaml | 1 + src/ytdl_sub/prebuilt_presets/music/singles.yaml | 4 ---- .../music/{other_websites.yaml => soundcloud.yaml} | 0 src/ytdl_sub/script/functions/print_functions.py | 3 +++ tests/unit/script/functions/test_print_functions.py | 3 +++ 6 files changed, 9 insertions(+), 5 deletions(-) rename src/ytdl_sub/prebuilt_presets/music/{other_websites.yaml => soundcloud.yaml} (100%) diff --git a/src/ytdl_sub/prebuilt_presets/music/albums_from_chapters.yaml b/src/ytdl_sub/prebuilt_presets/music/albums_from_chapters.yaml index 6c9b82ee..5881bfb4 100644 --- a/src/ytdl_sub/prebuilt_presets/music/albums_from_chapters.yaml +++ b/src/ytdl_sub/prebuilt_presets/music/albums_from_chapters.yaml @@ -22,4 +22,5 @@ presets: "YouTube Full Albums": preset: - - "_albums_from_chapters" \ No newline at end of file + - "_albums_from_chapters" + - "_throttle_protection" \ No newline at end of file diff --git a/src/ytdl_sub/prebuilt_presets/music/albums_from_playlists.yaml b/src/ytdl_sub/prebuilt_presets/music/albums_from_playlists.yaml index 22839279..7d847d27 100644 --- a/src/ytdl_sub/prebuilt_presets/music/albums_from_playlists.yaml +++ b/src/ytdl_sub/prebuilt_presets/music/albums_from_playlists.yaml @@ -18,6 +18,7 @@ presets: "YouTube Releases": preset: - "_albums_from_playlists" + - "_throttle_protection" "Bandcamp": preset: diff --git a/src/ytdl_sub/prebuilt_presets/music/singles.yaml b/src/ytdl_sub/prebuilt_presets/music/singles.yaml index 98675adc..04a9a031 100644 --- a/src/ytdl_sub/prebuilt_presets/music/singles.yaml +++ b/src/ytdl_sub/prebuilt_presets/music/singles.yaml @@ -2,10 +2,6 @@ presets: _music_base: - preset: - # ytdl-sub includes throttle prootection by default or all prebuilt presets. - # Can be disabled with override variable `enable_throttle_protection: False` - - "_throttle_protection" output_options: output_directory: "{music_directory}" diff --git a/src/ytdl_sub/prebuilt_presets/music/other_websites.yaml b/src/ytdl_sub/prebuilt_presets/music/soundcloud.yaml similarity index 100% rename from src/ytdl_sub/prebuilt_presets/music/other_websites.yaml rename to src/ytdl_sub/prebuilt_presets/music/soundcloud.yaml diff --git a/src/ytdl_sub/script/functions/print_functions.py b/src/ytdl_sub/script/functions/print_functions.py index a89bcd28..79113f1c 100644 --- a/src/ytdl_sub/script/functions/print_functions.py +++ b/src/ytdl_sub/script/functions/print_functions.py @@ -9,6 +9,9 @@ logger = Logger.get(name="preset") def _log(message: AnyArgument, level: Optional[Integer]) -> None: + if not str(message): + return + if level is None: logger.info(str(message)) return diff --git a/tests/unit/script/functions/test_print_functions.py b/tests/unit/script/functions/test_print_functions.py index a23f447d..56500d16 100644 --- a/tests/unit/script/functions/test_print_functions.py +++ b/tests/unit/script/functions/test_print_functions.py @@ -15,12 +15,15 @@ class TestPrintFunctions: ("{%print('hi mom', True)}", "hi mom", True), ("{%print('this is great', [1, 2, 3])}", "this is great", [1, 2, 3]), ("{%print([1, 2], [3, 4])}", "[1, 2]", [3, 4]), + ("{%print('', True)}", None, True), # print_if_true ("{%print_if_true('hi mom', True)}", "hi mom", True), ("{%print_if_true('hi mom', False)}", None, False), + ("{%print_if_true('', True)}", None, True), # print_if_false ("{%print_if_false('hi mom', True)}", None, True), ("{%print_if_false('hi mom', False)}", "hi mom", False), + ("{%print_if_false('', True)}", None, True), ], ) def test_print_functions(