fix
This commit is contained in:
+8
-2
@@ -29,6 +29,8 @@ from foodie_config import (
|
|||||||
load_dotenv()
|
load_dotenv()
|
||||||
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
||||||
|
|
||||||
|
IMAGE_EXPIRATION_DAYS = 7 # 7 days, consistent with foodie_automator_rss.py
|
||||||
|
|
||||||
def load_json_file(file_path, expiration_hours):
|
def load_json_file(file_path, expiration_hours):
|
||||||
entries = []
|
entries = []
|
||||||
cutoff = datetime.now(timezone.utc) - timedelta(hours=expiration_hours)
|
cutoff = datetime.now(timezone.utc) - timedelta(hours=expiration_hours)
|
||||||
@@ -1180,12 +1182,16 @@ def prepare_post_data(summary, title, main_topic=None):
|
|||||||
new_title = response.choices[0].message.content.strip()
|
new_title = response.choices[0].message.content.strip()
|
||||||
logging.info(f"Generated new title: '{new_title}'")
|
logging.info(f"Generated new title: '{new_title}'")
|
||||||
|
|
||||||
search_query, relevance_keywords, skip_flag = smart_image_and_filter(new_title, summary)
|
# Update to unpack four values
|
||||||
|
search_query, relevance_keywords, generated_main_topic, skip_flag = smart_image_and_filter(new_title, summary)
|
||||||
if skip_flag:
|
if skip_flag:
|
||||||
logging.info("Summary filtered out during post preparation")
|
logging.info("Summary filtered out during post preparation")
|
||||||
return None, None, None, None, None, None, None
|
return None, None, None, None, None, None, None
|
||||||
|
|
||||||
image_url, image_source, uploader, page_url = get_flickr_image(search_query, relevance_keywords, main_topic)
|
# Use the provided main_topic if available, otherwise use the generated one
|
||||||
|
effective_main_topic = main_topic if main_topic else generated_main_topic
|
||||||
|
|
||||||
|
image_url, image_source, uploader, page_url = get_flickr_image(search_query, relevance_keywords, effective_main_topic)
|
||||||
if not image_url:
|
if not image_url:
|
||||||
image_url, image_source, uploader, page_url = get_image(search_query)
|
image_url, image_source, uploader, page_url = get_image(search_query)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user