Add expire_url method
Call cache.delete()
Use session.cache.delete with delete_keys
Build new Request for cache.create_key
MODIFY
plextraktsync/commands/cache.py
plextraktsync/commands/cache.py
+from __future__ import annotations
+
from functools import partial
+from typing import TYPE_CHECKING
import click
from requests_cache import CachedSession
from plextraktsync.factory import factory
+if TYPE_CHECKING:
+ from typing import List
+
def get_sorted_cache(session: CachedSession, sorting: str, reverse: bool):
sorters = {
@@ -53,6 +59,17 @@ def render_json(data):
return dumps(decoded, indent=2)
+def expire_url(session: CachedSession, url: str):
+ from requests import Request
+ delete_keys: List[str] = []
+ for response in responses_by_url(session, url):
+ cache_key = response.cache_key if response.cache_key else session.cache.create_key(Request('GET', response.url))
+ delete_keys.append(cache_key)
+
+ print(f"Deleting: {delete_keys}")
+ session.cache.delete(*delete_keys)
+
+
def inspect_url(session: CachedSession, url: str):
matches = responses_by_url(session, url)
for m in matches:

Add expire_url method

- Call cache.delete()
- Use session.cache.delete with delete_keys
- Build new Request for cache.create_key