diff --git a/README.md b/README.md index fb99d0558..508334140 100644 --- a/README.md +++ b/README.md @@ -162,9 +162,6 @@ ## UPDATE * `yt-dlp --update-to 2023.10.07` upgrade/downgrade to tag `2023.10.07` if it exists on the current channel * `yt-dlp --update-to example/yt-dlp@2023.09.24` upgrade/downgrade to the release from the `example/yt-dlp` repository, tag `2023.09.24` -When running a yt-dlp version that is older than 90 days, you will see a warning message suggesting to update to the latest version. -You can suppress this warning by adding `--no-update` to your command or configuration file. - **Important**: Any user experiencing an issue with the `stable` release should install or update to the `nightly` release before submitting a bug report: ``` # To update to nightly from stable executable/binary: @@ -174,6 +171,9 @@ # To install nightly with pip: python3 -m pip install -U --pre "yt-dlp[default]" ``` +When running a yt-dlp version that is older than 90 days, you will see a warning message suggesting to update to the latest version. +You can suppress this warning by adding `--no-update` to your command or configuration file. + ## DEPENDENCIES Python versions 3.9+ (CPython) and 3.11+ (PyPy) are supported. Other versions and implementations may or may not work correctly. diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 9b391b278..77725257b 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -505,6 +505,7 @@ class YoutubeDL: force_keyframes_at_cuts: Re-encode the video when downloading ranges to get precise cuts noprogress: Do not print the progress bar live_from_start: Whether to download livestreams videos from the start + warn_when_outdated: Emit a warning if the yt-dlp version is older than 90 days The following parameters are not used by YoutubeDL itself, they are used by the downloader (see yt_dlp/downloader/common.py): @@ -704,8 +705,7 @@ def process_color_policy(stream): system_deprecation = _get_system_deprecation() if system_deprecation: self.deprecated_feature(system_deprecation.replace('\n', '\n ')) - - if self.params.get('warn_when_outdated'): + elif self.params.get('warn_when_outdated'): if version_age_warning := _get_version_age_warning(): self.report_warning(version_age_warning) diff --git a/yt_dlp/update.py b/yt_dlp/update.py index 327c8b2ae..1070ff972 100644 --- a/yt_dlp/update.py +++ b/yt_dlp/update.py @@ -173,25 +173,18 @@ def _get_system_deprecation(): def _get_version_age_warning(): - # Only yt-dlp guarantees a stable release at least every 3 months + # Only yt-dlp guarantees a stable release at least every 90 days if not ORIGIN.startswith('yt-dlp/'): return None - try: - version_parts = version_tuple(__version__) - if len(version_parts) < 3: - return None - - update_message = UPDATE_HINT or 'Run "yt-dlp --update" to update' - - if dt.date(*version_parts[:3]) < dt.datetime.now(dt.timezone.utc).date() - dt.timedelta(days=90): + with contextlib.suppress(Exception): + last_updated = dt.date(*version_tuple(__version__)[:3]) + if last_updated < dt.datetime.now(dt.timezone.utc).date() - dt.timedelta(days=90): return ('\n '.join(( f'Your yt-dlp version ({__version__}) is older than 90 days!', - 'It is strongly recommeded to always use the latest versions, as sites regularly change and extractors need to be adjusted.', - f'{update_message}. To suppress this warning, add "--no-update" to your command/config.'))) - except Exception: - pass - + 'It is strongly recommended to always use the latest version.', + f'{UPDATE_HINT or """Run "yt-dlp -U" to update"""}.', + 'To suppress this warning, add --no-update to your command/config.'))) return None