mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-22 06:00:00 +00:00
[compat] Add functools.cached_property
This commit is contained in:
parent
666c36d58d
commit
2762dbb17e
5 changed files with 21 additions and 7 deletions
|
@ -10,3 +10,15 @@
|
|||
cache # >= 3.9
|
||||
except NameError:
|
||||
cache = lru_cache(maxsize=None)
|
||||
|
||||
try:
|
||||
cached_property # >= 3.8
|
||||
except NameError:
|
||||
class cached_property:
|
||||
def __init__(self, func):
|
||||
update_wrapper(self, func)
|
||||
self.func = func
|
||||
|
||||
def __get__(self, instance, _):
|
||||
setattr(instance, self.func.__name__, self.func(instance))
|
||||
return getattr(instance, self.func.__name__)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
MultilinePrinter,
|
||||
QuietMultilinePrinter,
|
||||
)
|
||||
from ..compat import functools
|
||||
from ..utils import (
|
||||
NUMBER_RE,
|
||||
LockingUnsupportedError,
|
||||
|
@ -102,7 +103,7 @@ def to_screen(self, *args, **kargs):
|
|||
|
||||
__to_screen = to_screen
|
||||
|
||||
@property
|
||||
@functools.cached_property
|
||||
def FD_NAME(self):
|
||||
return re.sub(r'(?<!^)(?=[A-Z])', '_', type(self).__name__[:-2]).lower()
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import time
|
||||
|
||||
from .fragment import FragmentFD
|
||||
from ..compat import functools
|
||||
from ..compat import compat_setenv, compat_str
|
||||
from ..postprocessor.ffmpeg import EXT_TO_OUT_FORMATS, FFmpegPostProcessor
|
||||
from ..utils import (
|
||||
|
@ -74,7 +75,7 @@ def get_basename(cls):
|
|||
def EXE_NAME(cls):
|
||||
return cls.get_basename()
|
||||
|
||||
@property
|
||||
@functools.cached_property
|
||||
def exe(self):
|
||||
return self.EXE_NAME
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import time
|
||||
import xml.etree.ElementTree
|
||||
|
||||
from ..compat import functools, re
|
||||
from ..compat import (
|
||||
compat_cookiejar_Cookie,
|
||||
compat_cookies_SimpleCookie,
|
||||
|
@ -25,7 +26,6 @@
|
|||
compat_urllib_parse_urlencode,
|
||||
compat_urllib_request,
|
||||
compat_urlparse,
|
||||
re,
|
||||
)
|
||||
from ..downloader import FileDownloader
|
||||
from ..downloader.f4m import get_base_url, remove_encrypted_media
|
||||
|
@ -3748,7 +3748,7 @@ def extract_automatic_captions(self, *args, **kwargs):
|
|||
def _get_automatic_captions(self, *args, **kwargs):
|
||||
raise NotImplementedError('This method must be implemented by subclasses')
|
||||
|
||||
@property
|
||||
@functools.cached_property
|
||||
def _cookies_passed(self):
|
||||
"""Whether cookies have been passed to YoutubeDL"""
|
||||
return self.get_param('cookiefile') is not None or self.get_param('cookiesfrombrowser') is not None
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import calendar
|
||||
import copy
|
||||
import datetime
|
||||
import functools
|
||||
import hashlib
|
||||
import itertools
|
||||
import json
|
||||
|
@ -16,6 +15,7 @@
|
|||
import traceback
|
||||
|
||||
from .common import InfoExtractor, SearchInfoExtractor
|
||||
from ..compat import functools
|
||||
from ..compat import (
|
||||
compat_chr,
|
||||
compat_HTTPError,
|
||||
|
@ -534,7 +534,7 @@ def _extract_visitor_data(*args):
|
|||
args, [('VISITOR_DATA', ('INNERTUBE_CONTEXT', 'client', 'visitorData'), ('responseContext', 'visitorData'))],
|
||||
expected_type=str)
|
||||
|
||||
@property
|
||||
@functools.cached_property
|
||||
def is_authenticated(self):
|
||||
return bool(self._generate_sapisidhash_header())
|
||||
|
||||
|
@ -4402,7 +4402,7 @@ def _reload_with_unavailable_videos(self, item_id, data, ytcfg):
|
|||
check_get_keys='contents', fatal=False, ytcfg=ytcfg,
|
||||
note='Downloading API JSON with unavailable videos')
|
||||
|
||||
@property
|
||||
@functools.cached_property
|
||||
def skip_webpage(self):
|
||||
return 'webpage' in self._configuration_arg('skip', ie_key=YoutubeTabIE.ie_key())
|
||||
|
||||
|
|
Loading…
Reference in a new issue