diff --git a/src/ytdl_sub/downloaders/downloader.py b/src/ytdl_sub/downloaders/downloader.py index dc019ae1..fef21185 100644 --- a/src/ytdl_sub/downloaders/downloader.py +++ b/src/ytdl_sub/downloaders/downloader.py @@ -369,11 +369,17 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT], ABC): with self._listen_and_log_downloaded_info_json(log_prefix=log_prefix_on_info_json_dl): _ = self.extract_info(ytdl_options_overrides=ytdl_options_overrides, **kwargs) except RejectedVideoReached: - download_logger.debug("RejectedVideoReached, stopping additional downloads") + download_logger.info( + "RejectedVideoReached, stopping additional downloads. " + "Disable by setting `ytdl_options.break_on_reject` to False." + ) except ExistingVideoReached: - download_logger.debug("ExistingVideoReached, stopping additional downloads") + download_logger.info( + "ExistingVideoReached, stopping additional downloads. " + "Disable by setting `ytdl_options.break_on_existing` to False." + ) except MaxDownloadsReached: - download_logger.debug("MaxDownloadsReached, stopping additional downloads") + download_logger.info("MaxDownloadsReached, stopping additional downloads.") return self._get_entry_dicts_from_info_json_files() @@ -644,7 +650,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT], ABC): continue if (thumbnail_url := parent.get_thumbnail_url(thumbnail_id=thumbnail_id)) is None: - download_logger.warning("Failed to find thumbnail id '%s'", thumbnail_id) + download_logger.debug("Failed to find thumbnail id '%s'", thumbnail_id) continue if self._download_thumbnail( @@ -654,7 +660,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT], ABC): self.save_file(file_name=thumbnail_name) self._url_state.thumbnails_downloaded.add(thumbnail_name) else: - download_logger.warning("Failed to download thumbnail id '%s'", thumbnail_id) + download_logger.debug("Failed to download thumbnail id '%s'", thumbnail_id) def _download_url_thumbnails(self, collection_url: UrlValidator, entry: Entry): """ diff --git a/tests/conftest.py b/tests/conftest.py index 356e0d52..f1c1d589 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,7 +26,7 @@ def output_directory(): @contextlib.contextmanager -def assert_debug_log(logger: logging.Logger, expected_message: str): +def assert_logs(logger: logging.Logger, expected_message: str, log_level: str = "debug"): """ Patches any function, but calls the original function. Intended to see if the particular function is called. @@ -36,7 +36,7 @@ def assert_debug_log(logger: logging.Logger, expected_message: str): def _wrapped_debug(*args, **kwargs): debug_logger.info(*args, **kwargs) - with patch.object(logger, "debug", wraps=_wrapped_debug) as patched_debug: + with patch.object(logger, log_level, wraps=_wrapped_debug) as patched_debug: yield for call_args in patched_debug.call_args_list: diff --git a/tests/e2e/plugins/test_date_range.py b/tests/e2e/plugins/test_date_range.py index 3fe751a4..db77410e 100644 --- a/tests/e2e/plugins/test_date_range.py +++ b/tests/e2e/plugins/test_date_range.py @@ -2,7 +2,7 @@ import copy import mergedeep import pytest -from conftest import assert_debug_log +from conftest import assert_logs from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches @@ -67,9 +67,10 @@ class TestDateRange: ) if not dry_run: # try downloading again, ensure nothing more was downloaded - with assert_debug_log( + with assert_logs( logger=ytdl_sub.downloaders.downloader.download_logger, expected_message="ExistingVideoReached, stopping additional downloads", + log_level="info", ): transaction_log = recent_channel_subscription.download() assert_transaction_log_matches( @@ -137,9 +138,10 @@ class TestDateRange: # First, download recent vids. Always download since we want to test dry-run # on the rolling recent portion. - with assert_debug_log( + with assert_logs( logger=ytdl_sub.downloaders.downloader.download_logger, expected_message="RejectedVideoReached, stopping additional downloads", + log_level="info", ): transaction_log = recent_channel_subscription.download(dry_run=False) @@ -156,9 +158,10 @@ class TestDateRange: # Then, download the rolling recent vids subscription. This should remove one of the # two videos - with assert_debug_log( + with assert_logs( logger=ytdl_sub.downloaders.downloader.download_logger, expected_message="ExistingVideoReached, stopping additional downloads", + log_level="info", ): transaction_log = rolling_recent_channel_subscription.download(dry_run=dry_run) @@ -182,9 +185,10 @@ class TestDateRange: # Invoke the rolling download again, ensure downloading stopped early from it already # existing if not dry_run: - with assert_debug_log( + with assert_logs( logger=ytdl_sub.downloaders.downloader.download_logger, expected_message="ExistingVideoReached, stopping additional downloads", + log_level="info", ): transaction_log = rolling_recent_channel_subscription.download() diff --git a/tests/e2e/youtube/test_playlist.py b/tests/e2e/youtube/test_playlist.py index e2785951..d0f15b66 100644 --- a/tests/e2e/youtube/test_playlist.py +++ b/tests/e2e/youtube/test_playlist.py @@ -1,5 +1,5 @@ import pytest -from conftest import assert_debug_log +from conftest import assert_logs from e2e.conftest import mock_run_from_cli from expected_download import assert_expected_downloads from expected_transaction_log import assert_transaction_log_matches @@ -82,9 +82,10 @@ class TestPlaylist: # Ensure another invocation will hit ExistingVideoReached if not dry_run: - with assert_debug_log( + with assert_logs( logger=ytdl_sub.downloaders.downloader.download_logger, expected_message="ExistingVideoReached, stopping additional downloads", + log_level="info", ): _ = playlist_subscription.download() @@ -129,9 +130,10 @@ class TestPlaylist: if not dry_run: # Ensure another invocation will hit ExistingVideoReached - with assert_debug_log( + with assert_logs( logger=ytdl_sub.downloaders.downloader.download_logger, expected_message="ExistingVideoReached, stopping additional downloads", + log_level="info", ): _ = mock_run_from_cli(args=args)[0][1]