fix
This commit is contained in:
+22
-20
@@ -266,6 +266,7 @@ def curate_from_google_trends(posted_titles_data, posted_titles, used_images_dat
|
||||
summary = trend.get("summary", "")
|
||||
source_name = trend.get("source", "Google Trends")
|
||||
original_source = f'<a href="{link}">{source_name}</a>'
|
||||
original_url = link # Store for fallback
|
||||
|
||||
if title in posted_titles:
|
||||
logging.info(f"Skipping already posted trend: {title}")
|
||||
@@ -375,33 +376,34 @@ def curate_from_google_trends(posted_titles_data, posted_titles, used_images_dat
|
||||
should_post_tweet=True
|
||||
)
|
||||
if not post_id:
|
||||
logging.warning(f"Failed to post to WordPress for '{title}'")
|
||||
attempts += 1
|
||||
continue
|
||||
logging.warning(f"Failed to post to WordPress for '{title}', using original URL: {original_url}")
|
||||
post_url = original_url # Fallback to original trend URL
|
||||
else:
|
||||
logging.info(f"Posted to WordPress for {author_username}: {post_url}")
|
||||
|
||||
# Update post with actual post_url
|
||||
post_url_encoded = quote(post_url)
|
||||
share_links = share_links_template.format(post_url=post_url_encoded)
|
||||
post_data["content"] = f"{final_summary}\n\n{share_links}"
|
||||
post_data["post_id"] = post_id
|
||||
post_to_wp(
|
||||
post_data=post_data,
|
||||
category=category,
|
||||
link=link,
|
||||
author=author,
|
||||
image_url=None, # Skip image re-upload
|
||||
original_source=original_source,
|
||||
image_source=image_source,
|
||||
uploader=uploader,
|
||||
page_url=page_url,
|
||||
interest_score=interest_score,
|
||||
post_id=post_id,
|
||||
should_post_tweet=False
|
||||
)
|
||||
if post_id:
|
||||
post_to_wp(
|
||||
post_data=post_data,
|
||||
category=category,
|
||||
link=link,
|
||||
author=author,
|
||||
image_url=None, # Skip image re-upload
|
||||
original_source=original_source,
|
||||
image_source=image_source,
|
||||
uploader=uploader,
|
||||
page_url=page_url,
|
||||
interest_score=interest_score,
|
||||
post_id=post_id,
|
||||
should_post_tweet=False
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to post to WordPress for '{title}': {e}", exc_info=True)
|
||||
attempts += 1
|
||||
continue
|
||||
post_url = original_url # Fallback to original trend URL
|
||||
finally:
|
||||
is_posting = False
|
||||
|
||||
@@ -415,7 +417,7 @@ def curate_from_google_trends(posted_titles_data, posted_titles, used_images_dat
|
||||
used_images.add(image_url)
|
||||
logging.info(f"Saved image '{image_url}' to {USED_IMAGES_FILE}")
|
||||
|
||||
logging.info(f"***** SUCCESS: Posted '{post_data['title']}' (ID: {post_id}) from Google Trends *****")
|
||||
logging.info(f"***** SUCCESS: Posted '{post_data['title']}' (ID: {post_id or 'N/A'}) from Google Trends *****")
|
||||
return post_data, category, True
|
||||
|
||||
logging.info("No interesting Google Trend found after attempts")
|
||||
|
||||
Reference in New Issue
Block a user