diff --git a/README.md b/README.md index 727b83fd84..7358106169 100644 --- a/README.md +++ b/README.md @@ -1789,9 +1789,6 @@ The following extractors use this feature: * `pot_debug`: Enable debug logging for PO Token fetching. Either `true` or `false` (default `false`) * `fetch_pot`: Policy to use for fetching a PO Token from providers. `always` to always try fetch a PO Token regardless if the client requires one for the given context. `when_required` to only fetch a PO Token if the client requires one for the given context (default) -###### youtubepot-memory -* `max_size`: Max size of the PO Token LRU memory cache (default 25) - ###### youtubepot-webpo * `bind_to_visitor_id`: Whether to use the Visitor ID instead of Visitor Data for caching WebPO tokens. Either `true` or `false` (default `true`) diff --git a/test/test_pot/test_pot_builtin_memorycache.py b/test/test_pot/test_pot_builtin_memorycache.py index 79b2e15d4e..a42d7eeadc 100644 --- a/test/test_pot/test_pot_builtin_memorycache.py +++ b/test/test_pot/test_pot_builtin_memorycache.py @@ -4,7 +4,7 @@ from collections import OrderedDict import pytest from yt_dlp.extractor.youtube.pot._provider import IEContentProvider, BuiltInIEContentProvider from yt_dlp.utils import bug_reports_message -from yt_dlp.extractor.youtube.pot.builtin.cache.memory import MemoryLRUPCP, memorylru_preference +from yt_dlp.extractor.youtube.pot.builtin.cache.memory import MemoryLRUPCP, memorylru_preference, initialize_global_cache from yt_dlp.version import __version__ from yt_dlp.globals import _pot_memory_cache, _pot_cache_providers @@ -94,20 +94,6 @@ class TestMemoryLRUPCS: assert len(pcp.cache) == 0 assert pcp.get('key1') is None - def test_max_size_setting(self, ie, logger): - MAX_SIZE = 5 - called_max_size = 0 - - def initialize_cache(max_size): - nonlocal called_max_size - called_max_size = max_size - return OrderedDict(), threading.Lock(), max_size - - pcp = MemoryLRUPCP(ie, logger, {'max_size': [str(MAX_SIZE)]}, initialize_cache=initialize_cache) - - assert called_max_size == MAX_SIZE - assert pcp.max_size == MAX_SIZE - def test_use_global_cache_default(self, ie, logger): pcp = MemoryLRUPCP(ie, logger, {}) assert pcp.max_size == _pot_memory_cache.value['max_size'] == 25 @@ -123,7 +109,7 @@ class TestMemoryLRUPCS: pcp = MemoryLRUPCP(ie, logger, {}) assert pcp.max_size == _pot_memory_cache.value['max_size'] == 25 with pytest.raises(ValueError, match='Cannot change max_size of initialized global memory cache'): - MemoryLRUPCP(ie, logger, {'max_size': ['50']}) + initialize_global_cache(50) assert pcp.max_size == _pot_memory_cache.value['max_size'] == 25 diff --git a/yt_dlp/extractor/youtube/pot/builtin/cache/memory.py b/yt_dlp/extractor/youtube/pot/builtin/cache/memory.py index 2a7b7991e9..f89d49b4eb 100644 --- a/yt_dlp/extractor/youtube/pot/builtin/cache/memory.py +++ b/yt_dlp/extractor/youtube/pot/builtin/cache/memory.py @@ -12,7 +12,6 @@ from yt_dlp.extractor.youtube.pot.cache import ( register_pcp_preference, ) from yt_dlp.globals import _pot_memory_cache -from yt_dlp.utils import int_or_none def initialize_global_cache(max_size: int): @@ -39,8 +38,7 @@ class MemoryLRUPCP(PoTokenCacheProvider, BuiltInIEContentProvider): **kwargs, ): super().__init__(*args, **kwargs) - self.cache, self.lock, self.max_size = initialize_cache( - int_or_none(self.settings.get('max_size', [''])[0]) or self.DEFAULT_CACHE_SIZE) + self.cache, self.lock, self.max_size = initialize_cache(self.DEFAULT_CACHE_SIZE) def is_available(self) -> bool: return True