try
This commit is contained in:
@@ -87,7 +87,7 @@ class GoogleTrendsScraper:
|
|||||||
"""Load and return the set of used images."""
|
"""Load and return the set of used images."""
|
||||||
try:
|
try:
|
||||||
data = load_json_file(FILE_PATHS["used_images"], IMAGE_EXPIRATION_DAYS)
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error loading used images: {e}")
|
logger.error(f"Error loading used images: {e}")
|
||||||
return set()
|
return set()
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class RedditScraper:
|
|||||||
"""Load and return the set of used images."""
|
"""Load and return the set of used images."""
|
||||||
try:
|
try:
|
||||||
data = load_json_file(FILE_PATHS["used_images"], IMAGE_EXPIRATION_DAYS)
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error loading used images: {e}")
|
logger.error(f"Error loading used images: {e}")
|
||||||
return set()
|
return set()
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class RSSScraper:
|
|||||||
"""Load and return the set of used images."""
|
"""Load and return the set of used images."""
|
||||||
try:
|
try:
|
||||||
data = load_json_file(FILE_PATHS["used_images"], IMAGE_EXPIRATION_DAYS)
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error loading used images: {e}")
|
logger.error(f"Error loading used images: {e}")
|
||||||
return set()
|
return set()
|
||||||
|
|||||||
+1
-1
@@ -282,7 +282,7 @@ PERSONA_CONFIGS: Dict[str, PersonaConfig] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# File paths
|
# File paths
|
||||||
BASE_DIR = Path("/home/shane/foodie_automator")
|
BASE_DIR = Path("/home/blade/insiderfoodie/foodie_automator")
|
||||||
FILE_PATHS = {
|
FILE_PATHS = {
|
||||||
"posted_rss_titles": BASE_DIR / "posted_rss_titles.json",
|
"posted_rss_titles": BASE_DIR / "posted_rss_titles.json",
|
||||||
"posted_google_titles": BASE_DIR / "posted_google_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:
|
with open(USED_IMAGES_FILE, 'r') as f:
|
||||||
used_images = set(json.loads(line.strip())['url'] for line in f if line.strip())
|
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}")
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Failed to load used images: {e}")
|
logger.error(f"Failed to load used images: {e}")
|
||||||
used_images = set()
|
used_images = set()
|
||||||
@@ -911,6 +914,9 @@ def load_used_images():
|
|||||||
def save_used_images():
|
def save_used_images():
|
||||||
"""Save the set of used image URLs to file."""
|
"""Save the set of used image URLs to file."""
|
||||||
try:
|
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:
|
with open(USED_IMAGES_FILE, 'w') as f:
|
||||||
for url in used_images:
|
for url in used_images:
|
||||||
json.dump({'url': url, 'timestamp': datetime.now(timezone.utc).isoformat()}, f)
|
json.dump({'url': url, 'timestamp': datetime.now(timezone.utc).isoformat()}, f)
|
||||||
|
|||||||
Reference in New Issue
Block a user