|
|
|
|
@ -335,25 +335,43 @@ def curate_from_rss(): |
|
|
|
|
|
|
|
|
|
final_summary = insert_link_naturally(final_summary, source_name, link) |
|
|
|
|
|
|
|
|
|
post_data, author, category, image_url, image_source, uploader, page_url = prepare_post_data(final_summary, title, main_topic) |
|
|
|
|
if not post_data: |
|
|
|
|
print(f"Post data preparation failed for '{title}'") |
|
|
|
|
logging.info(f"Post data preparation failed for '{title}'") |
|
|
|
|
attempts += 1 |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords, main_topic) |
|
|
|
|
if not image_url: |
|
|
|
|
print(f"Flickr image fetch failed for '{image_query}', trying fallback") |
|
|
|
|
logging.warning(f"Flickr image fetch failed for '{image_query}', trying fallback") |
|
|
|
|
image_url, image_source, uploader, page_url = get_image(image_query) |
|
|
|
|
# Insert balanced author selection logic here |
|
|
|
|
x_post_counts = load_json_file('/home/shane/foodie_automator/x_post_counts.json', expiration_hours=24*30) |
|
|
|
|
monthly_counts = {entry['username']: entry['monthly_count'] for entry in x_post_counts} |
|
|
|
|
low_post_authors = [u for u, c in monthly_counts.items() if c < 3] # Authors with <3 posts |
|
|
|
|
|
|
|
|
|
if low_post_authors: |
|
|
|
|
author_username = random.choice(low_post_authors) |
|
|
|
|
author = next(a for a in AUTHORS if a['username'] == author_username) |
|
|
|
|
logging.info(f"Prioritizing low-post author: {author_username}") |
|
|
|
|
post_data = { |
|
|
|
|
"title": generate_title_from_summary(final_summary), |
|
|
|
|
"content": final_summary, |
|
|
|
|
"status": "publish", |
|
|
|
|
"author": author_username, |
|
|
|
|
"categories": [generate_category_from_summary(final_summary)] |
|
|
|
|
} |
|
|
|
|
category = post_data["categories"][0] |
|
|
|
|
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords, main_topic) |
|
|
|
|
if not image_url: |
|
|
|
|
print(f"All image uploads failed for '{title}' - posting without image") |
|
|
|
|
logging.warning(f"All image uploads failed for '{title}' - posting without image") |
|
|
|
|
image_source = None |
|
|
|
|
uploader = None |
|
|
|
|
page_url = None |
|
|
|
|
print(f"Flickr image fetch failed for '{image_query}', trying fallback") |
|
|
|
|
logging.warning(f"Flickr image fetch failed for '{image_query}', trying fallback") |
|
|
|
|
image_url, image_source, uploader, page_url = get_image(image_query) |
|
|
|
|
if not image_url: |
|
|
|
|
print(f"All image uploads failed for '{title}' - posting without image") |
|
|
|
|
logging.warning(f"All image uploads failed for '{title}' - posting without image") |
|
|
|
|
image_source = None |
|
|
|
|
uploader = None |
|
|
|
|
page_url = None |
|
|
|
|
else: |
|
|
|
|
post_data, author, category, image_url, image_source, uploader, page_url = prepare_post_data(final_summary, title, main_topic) |
|
|
|
|
if not post_data: |
|
|
|
|
print(f"Post data preparation failed for '{title}'") |
|
|
|
|
logging.info(f"Post data preparation failed for '{title}'") |
|
|
|
|
attempts += 1 |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
# ... (rest of the function: image fetching, posting logic, etc.) |
|
|
|
|
hook = get_dynamic_hook(post_data["title"]).strip() |
|
|
|
|
|
|
|
|
|
share_prompt = get_viral_share_prompt(post_data["title"], final_summary) |
|
|
|
|
|