From 7dc0b45ce532c29caee09fbb2b9fc47e62726181 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 23 Nov 2024 10:06:33 -0800 Subject: [PATCH 1/3] [BACKEND] More informative info logs --- src/ytdl_sub/downloaders/ytdlp.py | 14 +++++++++----- src/ytdl_sub/plugins/subtitles.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ytdl_sub/downloaders/ytdlp.py b/src/ytdl_sub/downloaders/ytdlp.py index 42f3d865..f1136c1e 100644 --- a/src/ytdl_sub/downloaders/ytdlp.py +++ b/src/ytdl_sub/downloaders/ytdlp.py @@ -123,7 +123,7 @@ class YTDLP: del copied_ytdl_options_overrides["download_archive"] if num_tries < cls._EXTRACT_ENTRY_NUM_RETRIES: - cls.logger.debug( + cls.logger.info( "Failed to download entry. Retrying %d / %d", num_tries, cls._EXTRACT_ENTRY_NUM_RETRIES, @@ -222,14 +222,18 @@ class YTDLP: ): cls.extract_info(ytdl_options_overrides=ytdl_options_overrides, **kwargs) except RejectedVideoReached: - cls.logger.debug( + cls.logger.info( "RejectedVideoReached, stopping additional downloads " - "(Can be disable by setting `date_range.breaking` to False)." + "(Can be disable by setting `date_range.breaks` to False. " + "If this is unexpected, " + "run with --log-level verbose to see the yt-dlp logs on why it stopped." ) except ExistingVideoReached: - cls.logger.debug( + cls.logger.info( "ExistingVideoReached, stopping additional downloads. " "(Can be disable by setting `ytdl_options.break_on_existing` to False)." + "If this is unexpected, " + "run with --log-level verbose to see the yt-dlp logs on why it stopped." ) except MaxDownloadsReached: cls.logger.info("MaxDownloadsReached, stopping additional downloads.") @@ -247,7 +251,7 @@ class YTDLP: if uploader_id in entry_ids or not (uploader_url := entry_dict.get("uploader_url")): continue - cls.logger.debug("Attempting to get parent metadata from URL %s", uploader_url) + cls.logger.info("Attempting to get parent metadata from URL %s", uploader_url) parent_dict: Optional[Dict] = None try: parent_dict = cls.extract_info( diff --git a/src/ytdl_sub/plugins/subtitles.py b/src/ytdl_sub/plugins/subtitles.py index ecf32a1d..a7a065fe 100644 --- a/src/ytdl_sub/plugins/subtitles.py +++ b/src/ytdl_sub/plugins/subtitles.py @@ -193,7 +193,7 @@ class SubtitlesPlugin(Plugin[SubtitleOptions]): """ requested_subtitles = entry.get(v.requested_subtitles, expected_type=dict) if not requested_subtitles: - logger.debug("subtitles not found for %s", entry.title) + logger.info("subtitles not found for %s", entry.title) return None file_metadata: Optional[FileMetadata] = None From 64b62b58811bfe099b3d04c4812a2cf2a4e46268 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 23 Nov 2024 10:40:51 -0800 Subject: [PATCH 2/3] better messaging --- src/ytdl_sub/downloaders/ytdlp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ytdl_sub/downloaders/ytdlp.py b/src/ytdl_sub/downloaders/ytdlp.py index f1136c1e..31f9ccdb 100644 --- a/src/ytdl_sub/downloaders/ytdlp.py +++ b/src/ytdl_sub/downloaders/ytdlp.py @@ -226,14 +226,14 @@ class YTDLP: "RejectedVideoReached, stopping additional downloads " "(Can be disable by setting `date_range.breaks` to False. " "If this is unexpected, " - "run with --log-level verbose to see the yt-dlp logs on why it stopped." + "run with `--log-level verbose` to see the yt-dlp logs on why it stopped)" ) except ExistingVideoReached: cls.logger.info( "ExistingVideoReached, stopping additional downloads. " - "(Can be disable by setting `ytdl_options.break_on_existing` to False)." - "If this is unexpected, " - "run with --log-level verbose to see the yt-dlp logs on why it stopped." + "(Can be disable by setting `ytdl_options.break_on_existing` to False. This will " + "force yt-dlp to continue scraping all metadata to grab any files you may have " + "missed)" ) except MaxDownloadsReached: cls.logger.info("MaxDownloadsReached, stopping additional downloads.") From 577afba4ce99095759fa98a9b13c69b6c48de28d Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Fri, 6 Jun 2025 10:05:39 -0700 Subject: [PATCH 3/3] better messages --- src/ytdl_sub/downloaders/ytdlp.py | 21 ++++++++++++--------- src/ytdl_sub/plugins/subtitles.py | 2 +- src/ytdl_sub/utils/logger.py | 9 +++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/ytdl_sub/downloaders/ytdlp.py b/src/ytdl_sub/downloaders/ytdlp.py index 31f9ccdb..3413e716 100644 --- a/src/ytdl_sub/downloaders/ytdlp.py +++ b/src/ytdl_sub/downloaders/ytdlp.py @@ -17,7 +17,7 @@ from yt_dlp.utils import RejectedVideoReached from ytdl_sub.thread.log_entries_downloaded_listener import LogEntriesDownloadedListener from ytdl_sub.utils.exceptions import FileNotDownloadedException -from ytdl_sub.utils.logger import Logger +from ytdl_sub.utils.logger import Logger, LoggerLevels class YTDLP: @@ -123,10 +123,17 @@ class YTDLP: del copied_ytdl_options_overrides["download_archive"] if num_tries < cls._EXTRACT_ENTRY_NUM_RETRIES: + maybe_inform_verbose = "" + if Logger.get_log_level().level < LoggerLevels.VERBOSE.level: + maybe_inform_verbose = ( + ". Consider inspecting the yt-dlp logs using `--log-level verbose` to " + "see the issue." + ) cls.logger.info( - "Failed to download entry. Retrying %d / %d", + "Failed to download entry. Retrying %d / %d%s", num_tries, cls._EXTRACT_ENTRY_NUM_RETRIES, + maybe_inform_verbose ) # Still return if the media file downloaded (thumbnail could be missing) @@ -223,17 +230,13 @@ class YTDLP: cls.extract_info(ytdl_options_overrides=ytdl_options_overrides, **kwargs) except RejectedVideoReached: cls.logger.info( - "RejectedVideoReached, stopping additional downloads " - "(Can be disable by setting `date_range.breaks` to False. " - "If this is unexpected, " - "run with `--log-level verbose` to see the yt-dlp logs on why it stopped)" + "RejectedVideoReached, stopping additional downloads. " + "Can be disable by setting `date_range.breaks` to False." ) except ExistingVideoReached: cls.logger.info( "ExistingVideoReached, stopping additional downloads. " - "(Can be disable by setting `ytdl_options.break_on_existing` to False. This will " - "force yt-dlp to continue scraping all metadata to grab any files you may have " - "missed)" + "Can be disable by setting `ytdl_options.break_on_existing` to False." ) except MaxDownloadsReached: cls.logger.info("MaxDownloadsReached, stopping additional downloads.") diff --git a/src/ytdl_sub/plugins/subtitles.py b/src/ytdl_sub/plugins/subtitles.py index 712a40e8..d5ebdf0f 100644 --- a/src/ytdl_sub/plugins/subtitles.py +++ b/src/ytdl_sub/plugins/subtitles.py @@ -198,7 +198,7 @@ class SubtitlesPlugin(Plugin[SubtitleOptions]): """ requested_subtitles = entry.get(v.requested_subtitles, expected_type=dict) if not requested_subtitles: - logger.info("subtitles not found for %s", entry.title) + logger.info("Subtitles not found for %s", entry.title) return None file_metadata: Optional[FileMetadata] = None diff --git a/src/ytdl_sub/utils/logger.py b/src/ytdl_sub/utils/logger.py index fcd734d5..0ee8b7da 100644 --- a/src/ytdl_sub/utils/logger.py +++ b/src/ytdl_sub/utils/logger.py @@ -125,6 +125,15 @@ class Logger: """ cls._LOGGER_LEVEL = LoggerLevels.from_str(name=log_level_name) + @classmethod + def get_log_level(cls) -> LoggerLevel: + """ + Returns + ------- + Application's log level + """ + return cls._LOGGER_LEVEL + @classmethod def _get_formatter(cls) -> logging.Formatter: """