-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrss_cache.py
More file actions
27 lines (21 loc) · 794 Bytes
/
Copy pathrss_cache.py
File metadata and controls
27 lines (21 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
import os
import logging
logger = logging.getLogger(__name__)
CACHE_FILE = os.path.join(os.path.dirname(__file__), "rss_seen.json")
def load_seen_entries() -> dict:
if os.path.exists(CACHE_FILE):
try:
with open(CACHE_FILE, "r", encoding="utf-8") as f:
data = json.load(f)
if isinstance(data, dict):
return data
except Exception as e:
logger.error(f"Failed to load RSS cache from {CACHE_FILE}: {e}")
return {}
def save_seen_entries(data: dict) -> None:
try:
with open(CACHE_FILE, "w", encoding="utf-8") as f:
json.dump(data, f)
except Exception as e:
logger.error(f"Failed to save RSS cache to {CACHE_FILE}: {e}")