From 24093d52a768e624a3ecd9d834f3239f64e1bf2c Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 17 Jul 2022 17:36:15 +0530 Subject: [PATCH] [update] Prepare to remove Python 3.6 support --- yt_dlp/YoutubeDL.py | 4 ++-- yt_dlp/update.py | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 0f8a51dbe..d6dac7a90 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -588,8 +588,8 @@ def __init__(self, params=None, auto_init=True): current_version = sys.version_info[:2] if current_version < MIN_RECOMMENDED: msg = ('Support for Python version %d.%d has been deprecated. ' - 'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details. ' - 'You will recieve only one more update on this version') + 'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details.' + '\n You will no longer recieve updates on this version') if current_version < MIN_SUPPORTED: msg = 'Python version %d.%d is no longer supported' self.deprecation_warning( diff --git a/yt_dlp/update.py b/yt_dlp/update.py index 7f15aa211..92c07acc1 100644 --- a/yt_dlp/update.py +++ b/yt_dlp/update.py @@ -88,8 +88,7 @@ def __init__(self, ydl): @functools.cached_property def _tag(self): - latest = self._get_version_info('latest')['tag_name'] - if version_tuple(__version__) >= version_tuple(latest): + if version_tuple(__version__) >= version_tuple(self.latest_version): return 'latest' identifier = f'{detect_variant()} {system_identifier()}' @@ -113,9 +112,16 @@ def current_version(self): @property def new_version(self): - """Version of the latest release""" + """Version of the latest release we can update to""" + if self._tag.startswith('tags/'): + return self._tag[5:] return self._get_version_info(self._tag)['tag_name'] + @property + def latest_version(self): + """Version of the latest release""" + return self._get_version_info('latest')['tag_name'] + @property def has_update(self): """Whether there is an update available""" @@ -161,13 +167,15 @@ def check_update(self): """Report whether there is an update available""" try: self.ydl.to_screen( - f'Latest version: {self.new_version}, Current version: {self.current_version}') + f'Latest version: {self.latest_version}, Current version: {self.current_version}') + if not self.has_update: + if self._tag == 'latest': + return self.ydl.to_screen(f'yt-dlp is up to date ({__version__})') + return self.ydl.report_warning( + 'yt-dlp cannot be updated any further since you are on an older Python version') except Exception: return self._report_network_error('obtain version info', delim='; Please try again later or') - if not self.has_update: - return self.ydl.to_screen(f'yt-dlp is up to date ({__version__})') - if not is_non_updateable(): self.ydl.to_screen(f'Current Build Hash {_sha256_file(self.filename)}') return True