add max tweet to author limit

This commit is contained in:
2025-05-08 10:38:58 +10:00
parent 4adaa3442c
commit 2158c780ca
6 changed files with 187 additions and 188 deletions
+20 -29
View File
@@ -346,37 +346,28 @@ def curate_from_reddit():
final_summary = insert_link_naturally(final_summary, source_name, link)
# Balanced author selection
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]
# Use round-robin author selection
author = get_next_author_round_robin()
author_username = author["username"]
logging.info(f"Selected author via round-robin: {author_username}")
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)
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:
image_url, image_source, uploader, page_url = get_image(image_query)
if not image_url:
image_url, image_source, uploader, page_url = get_image(image_query)
if not image_url:
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:
attempts += 1
continue
logging.warning(f"All image uploads failed for '{title}' - posting without image")
image_source = None
uploader = None
page_url = None
hook = get_dynamic_hook(post_data["title"]).strip()
share_prompt = get_viral_share_prompt(post_data["title"], final_summary)