mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-24 19:54:47 +00:00
change key generation
This commit is contained in:
parent
b2e9af41eb
commit
5a2b9f56af
@ -578,7 +578,8 @@ class TestPoTokenCache:
|
|||||||
assert cache.get(pot_request) is None
|
assert cache.get(pot_request) is None
|
||||||
cache.store(pot_request, response)
|
cache.store(pot_request, response)
|
||||||
assert len(memorypcp.cache) == 1
|
assert len(memorypcp.cache) == 1
|
||||||
assert hashlib.sha256(f'_dlp_cachev1_pExampleProviderv{pot_request.video_id}'.encode()).hexdigest() in memorypcp.cache
|
assert hashlib.sha256(
|
||||||
|
f"{{'_dlp_cache': 'v1', '_p': 'ExampleProvider', 'v': '{pot_request.video_id}'}}".encode()).hexdigest() in memorypcp.cache
|
||||||
|
|
||||||
# The second spec provider returns the exact same key bindings as the first one,
|
# The second spec provider returns the exact same key bindings as the first one,
|
||||||
# however the PoTokenCache should use the provider key to differentiate between them
|
# however the PoTokenCache should use the provider key to differentiate between them
|
||||||
@ -591,7 +592,8 @@ class TestPoTokenCache:
|
|||||||
assert cache.get(pot_request) is None
|
assert cache.get(pot_request) is None
|
||||||
cache.store(pot_request, response)
|
cache.store(pot_request, response)
|
||||||
assert len(memorypcp.cache) == 2
|
assert len(memorypcp.cache) == 2
|
||||||
assert hashlib.sha256(f'_dlp_cachev1_pExampleProviderTwov{pot_request.video_id}'.encode()).hexdigest() in memorypcp.cache
|
assert hashlib.sha256(
|
||||||
|
f"{{'_dlp_cache': 'v1', '_p': 'ExampleProviderTwo', 'v': '{pot_request.video_id}'}}".encode()).hexdigest() in memorypcp.cache
|
||||||
|
|
||||||
def test_cache_provider_preferences(self, pot_request, ie, logger):
|
def test_cache_provider_preferences(self, pot_request, ie, logger):
|
||||||
pcp_one = create_memory_pcp(ie, logger, provider_key='memory_pcp_one')
|
pcp_one = create_memory_pcp(ie, logger, provider_key='memory_pcp_one')
|
||||||
|
|||||||
@ -144,7 +144,7 @@ class PoTokenCache:
|
|||||||
return bindings_cleaned
|
return bindings_cleaned
|
||||||
|
|
||||||
def _generate_key(self, bindings: dict) -> str:
|
def _generate_key(self, bindings: dict) -> str:
|
||||||
binding_string = ''.join(f'{k}{v}' for k, v in sorted(bindings.items()))
|
binding_string = ''.join(repr(dict(sorted(bindings.items()))))
|
||||||
return hashlib.sha256(binding_string.encode()).hexdigest()
|
return hashlib.sha256(binding_string.encode()).hexdigest()
|
||||||
|
|
||||||
def get(self, request: PoTokenRequest) -> PoTokenResponse | None:
|
def get(self, request: PoTokenRequest) -> PoTokenResponse | None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user