try
This commit is contained in:
@@ -87,7 +87,7 @@ class GoogleTrendsScraper:
|
||||
"""Load and return the set of used images."""
|
||||
try:
|
||||
data = load_json_file(FILE_PATHS["used_images"], IMAGE_EXPIRATION_DAYS)
|
||||
return {entry["title"] for entry in data if "title" in entry}
|
||||
return {entry["url"] for entry in data if "url" in entry}
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading used images: {e}")
|
||||
return set()
|
||||
|
||||
@@ -146,7 +146,7 @@ class RedditScraper:
|
||||
"""Load and return the set of used images."""
|
||||
try:
|
||||
data = load_json_file(FILE_PATHS["used_images"], IMAGE_EXPIRATION_DAYS)
|
||||
return {entry["title"] for entry in data if "title" in entry}
|
||||
return {entry["url"] for entry in data if "url" in entry}
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading used images: {e}")
|
||||
return set()
|
||||
|
||||
@@ -142,7 +142,7 @@ class RSSScraper:
|
||||
"""Load and return the set of used images."""
|
||||
try:
|
||||
data = load_json_file(FILE_PATHS["used_images"], IMAGE_EXPIRATION_DAYS)
|
||||
return {entry["title"] for entry in data if "title" in entry}
|
||||
return {entry["url"] for entry in data if "url" in entry}
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading used images: {e}")
|
||||
return set()
|
||||
|
||||
+1
-1
@@ -282,7 +282,7 @@ PERSONA_CONFIGS: Dict[str, PersonaConfig] = {
|
||||
}
|
||||
|
||||
# File paths
|
||||
BASE_DIR = Path("/home/shane/foodie_automator")
|
||||
BASE_DIR = Path("/home/blade/insiderfoodie/foodie_automator")
|
||||
FILE_PATHS = {
|
||||
"posted_rss_titles": BASE_DIR / "posted_rss_titles.json",
|
||||
"posted_google_titles": BASE_DIR / "posted_google_titles.json",
|
||||
|
||||
@@ -904,6 +904,9 @@ def load_used_images():
|
||||
with open(USED_IMAGES_FILE, 'r') as f:
|
||||
used_images = set(json.loads(line.strip())['url'] for line in f if line.strip())
|
||||
logger.info(f"Loaded {len(used_images)} used images from {USED_IMAGES_FILE}")
|
||||
else:
|
||||
used_images = set()
|
||||
logger.info(f"Used images file {USED_IMAGES_FILE} does not exist yet. Starting with empty set.")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to load used images: {e}")
|
||||
used_images = set()
|
||||
@@ -911,6 +914,9 @@ def load_used_images():
|
||||
def save_used_images():
|
||||
"""Save the set of used image URLs to file."""
|
||||
try:
|
||||
# Create directory if it doesn't exist
|
||||
os.makedirs(os.path.dirname(USED_IMAGES_FILE), exist_ok=True)
|
||||
|
||||
with open(USED_IMAGES_FILE, 'w') as f:
|
||||
for url in used_images:
|
||||
json.dump({'url': url, 'timestamp': datetime.now(timezone.utc).isoformat()}, f)
|
||||
|
||||
Reference in New Issue
Block a user