This commit is contained in:
2025-05-13 19:21:13 +10:00
parent 6e3f055f3a
commit 37ad5349ac
3 changed files with 56 additions and 16 deletions
+17 -6
View File
@@ -303,7 +303,6 @@ def curate_from_google(item, original_source, source_name, link, page_url):
logger.warning(f"Failed to summarize Google item: {item.get('title', 'unknown')}")
return None, None
# Remove the original title from the summary if present
if item.get('title', '') in summary:
summary = summary.replace(item.get('title', ''), "").strip()
while "\n\n\n" in summary:
@@ -314,11 +313,24 @@ def curate_from_google(item, original_source, source_name, link, page_url):
logger.warning(f"Failed to insert link for Google item: {item.get('title', 'unknown')}")
return None, None
post_data, author, category, image_url, image_source, uploader, page_url = prepare_post_data(final_summary, item.get('title', 'unknown'))
if not post_data:
result = prepare_post_data(final_summary, item.get('title', 'unknown'))
if not result:
logger.info(f"Post preparation failed for Google item: {item.get('title', 'unknown')}")
return None, None
logger.debug(f"prepare_post_data returned {len(result)} values: {result}")
if len(result) < 7:
logger.error(f"prepare_post_data returned too few values: {result}")
return None, None
post_data = result[0]
author = result[1]
category = result[2]
image_url = result[3]
image_source = result[4]
uploader = result[5]
page_url = result[6]
share_text = f"Check out this tasty find: {post_data['title']}"
share_text_encoded = quote(share_text)
share_links_template = (
@@ -327,7 +339,6 @@ def curate_from_google(item, original_source, source_name, link, page_url):
'<a href="https://www.facebook.com/sharer/sharer.php?u={post_url}">Facebook</a>'
)
# First call: Post without share links
post_data["content"] = final_summary
post_id, post_url = post_to_wp(
post_data=post_data,
@@ -348,7 +359,6 @@ def curate_from_google(item, original_source, source_name, link, page_url):
logger.warning(f"Failed to post Google item to WP: {post_data['title']}")
return None, None
# Second call: Update with share links
post_url_encoded = quote(post_url)
share_links = share_links_template.format(post_url=post_url_encoded, share_text=share_text_encoded)
post_data["content"] = f"{final_summary}\n\n{share_links}"
@@ -364,7 +374,8 @@ def curate_from_google(item, original_source, source_name, link, page_url):
page_url=page_url,
interest_score=interest_score,
post_id=post_id,
should_post_tweet=False
should_post_tweet=False,
summary=final_summary
)
if post_id: