mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-15 00:48:28 +00:00
Warn on severely outdated yt-dlp version
This commit is contained in:
parent
f799a4b472
commit
fd8a748493
@ -73,6 +73,7 @@
|
|||||||
from .update import (
|
from .update import (
|
||||||
REPOSITORY,
|
REPOSITORY,
|
||||||
_get_system_deprecation,
|
_get_system_deprecation,
|
||||||
|
_get_version_age_warning,
|
||||||
_make_label,
|
_make_label,
|
||||||
current_git_head,
|
current_git_head,
|
||||||
detect_variant,
|
detect_variant,
|
||||||
@ -704,6 +705,11 @@ def process_color_policy(stream):
|
|||||||
if system_deprecation:
|
if system_deprecation:
|
||||||
self.deprecated_feature(system_deprecation.replace('\n', '\n '))
|
self.deprecated_feature(system_deprecation.replace('\n', '\n '))
|
||||||
|
|
||||||
|
if self.params.get('update_self') is None:
|
||||||
|
version_age_warning = _get_version_age_warning()
|
||||||
|
if version_age_warning:
|
||||||
|
self.report_warning(version_age_warning)
|
||||||
|
|
||||||
if self.params.get('allow_unplayable_formats'):
|
if self.params.get('allow_unplayable_formats'):
|
||||||
self.report_warning(
|
self.report_warning(
|
||||||
f'You have asked for {self._format_err("UNPLAYABLE", self.Styles.EMPHASIS)} formats to be listed/downloaded. '
|
f'You have asked for {self._format_err("UNPLAYABLE", self.Styles.EMPHASIS)} formats to be listed/downloaded. '
|
||||||
|
@ -974,6 +974,7 @@ def parse_options(argv=None):
|
|||||||
'_warnings': warnings,
|
'_warnings': warnings,
|
||||||
'_deprecation_warnings': deprecation_warnings,
|
'_deprecation_warnings': deprecation_warnings,
|
||||||
'compat_opts': opts.compat_opts,
|
'compat_opts': opts.compat_opts,
|
||||||
|
'update_self': opts.update_self,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import datetime as dt
|
||||||
import functools
|
import functools
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
@ -171,6 +172,30 @@ def _get_system_deprecation():
|
|||||||
return f'Support for Python version {major}.{minor} has been deprecated. {PYTHON_MSG}'
|
return f'Support for Python version {major}.{minor} has been deprecated. {PYTHON_MSG}'
|
||||||
|
|
||||||
|
|
||||||
|
def _get_version_age_warning():
|
||||||
|
# Only yt-dlp guarantees a stable release at least every 3 months
|
||||||
|
if not ORIGIN.startswith('yt-dlp/'):
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
version_parts = __version__.split('.')
|
||||||
|
if len(version_parts) < 3:
|
||||||
|
return None
|
||||||
|
|
||||||
|
year, month, day = map(int, version_parts[:3])
|
||||||
|
version_date = dt.date(year, month, day)
|
||||||
|
|
||||||
|
if version_date < dt.date.today() - 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.',
|
||||||
|
'Run "yt-dlp --update" to update. To suppress this warning, add "--no-update" to your command/config.')))
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _sha256_file(path):
|
def _sha256_file(path):
|
||||||
h = hashlib.sha256()
|
h = hashlib.sha256()
|
||||||
mv = memoryview(bytearray(128 * 1024))
|
mv = memoryview(bytearray(128 * 1024))
|
||||||
|
Loading…
Reference in New Issue
Block a user