try
This commit is contained in:
+47
-23
@@ -27,7 +27,8 @@ from foodie_utils import (
|
||||
upload_image_to_wp, determine_paragraph_count, insert_link_naturally,
|
||||
is_interesting, generate_title_from_summary, summarize_with_gpt4o,
|
||||
generate_category_from_summary, post_to_wp, prepare_post_data,
|
||||
select_best_author, smart_image_and_filter, get_flickr_image
|
||||
select_best_author, smart_image_and_filter, get_flickr_image,
|
||||
select_best_persona
|
||||
)
|
||||
from foodie_hooks import get_dynamic_hook, get_viral_share_prompt
|
||||
from dotenv import load_dotenv
|
||||
@@ -248,30 +249,53 @@ class RSSScraper:
|
||||
num_paragraphs = determine_paragraph_count(interest_score)
|
||||
extra_prompt = (
|
||||
f"Generate exactly {num_paragraphs} paragraphs.\n"
|
||||
f"FOCUS: Summarize ONLY the provided content, explicitly mentioning '{title}' and sticking to its specific topic and details.\n"
|
||||
f"Do NOT introduce unrelated concepts.\n"
|
||||
f"Expand on the core idea with relevant context about its appeal or significance.\n"
|
||||
f"Do not include emojis in the summary."
|
||||
f"Focus on the most interesting aspects of the content.\n"
|
||||
f"Use a {select_best_persona(interest_score, content)} tone.\n"
|
||||
f"Make it engaging and shareable."
|
||||
)
|
||||
|
||||
final_summary = summarize_with_gpt4o(
|
||||
scoring_content,
|
||||
source_name,
|
||||
link,
|
||||
interest_score=interest_score,
|
||||
extra_prompt=extra_prompt
|
||||
)
|
||||
|
||||
if not final_summary:
|
||||
logger.info(f"Summary failed for '{title}'")
|
||||
|
||||
summary = summarize_with_gpt4o(content, source_name, link, interest_score, extra_prompt)
|
||||
if not summary:
|
||||
logger.warning(f"Failed to generate summary for '{title}'")
|
||||
continue
|
||||
|
||||
final_summary = insert_link_naturally(final_summary, source_name, link)
|
||||
post_data, author, category, image_url, image_source, uploader, pixabay_url = prepare_post_data(final_summary, title)
|
||||
|
||||
if post_data and author:
|
||||
return post_data, author, random.randint(600, 1800)
|
||||
|
||||
|
||||
summary = insert_link_naturally(summary, source_name, link)
|
||||
if not summary:
|
||||
logger.warning(f"Failed to insert link for '{title}'")
|
||||
continue
|
||||
|
||||
post_data, author, category, image_url, image_source, uploader, page_url = prepare_post_data(
|
||||
summary, title, f"RSS: {source_name}"
|
||||
)
|
||||
|
||||
if not post_data or not author:
|
||||
logger.warning(f"Failed to prepare post data for '{title}'")
|
||||
continue
|
||||
|
||||
try:
|
||||
post_id, post_url = post_to_wp(
|
||||
post_data=post_data,
|
||||
category=category,
|
||||
link=link,
|
||||
author=author,
|
||||
image_url=image_url,
|
||||
original_source=source_name,
|
||||
image_source=image_source,
|
||||
uploader=uploader,
|
||||
pixabay_url=page_url,
|
||||
interest_score=interest_score
|
||||
)
|
||||
|
||||
if post_id and post_url:
|
||||
logger.info(f"Successfully posted '{title}' to WordPress (ID: {post_id})")
|
||||
self.posted_titles.add(title)
|
||||
save_json_file(FILE_PATHS["posted_rss_titles"], title, datetime.now(timezone.utc).isoformat())
|
||||
return post_data, author["username"], random.randint(600, 1800)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in RSS automator: {e}")
|
||||
continue
|
||||
|
||||
return None, None, random.randint(600, 1800)
|
||||
|
||||
def run_rss_automator():
|
||||
|
||||
Reference in New Issue
Block a user