fix
This commit is contained in:
@@ -215,7 +215,6 @@ def curate_from_google_trends(geo_list=['US']):
|
|||||||
attempts += 1
|
attempts += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Fetch additional context via DDG
|
|
||||||
ddg_context = fetch_duckduckgo_news_context(title)
|
ddg_context = fetch_duckduckgo_news_context(title)
|
||||||
scoring_content = f"{title}\n\n{summary}\n\nAdditional Context: {ddg_context}"
|
scoring_content = f"{title}\n\n{summary}\n\nAdditional Context: {ddg_context}"
|
||||||
interest_score = is_interesting(scoring_content)
|
interest_score = is_interesting(scoring_content)
|
||||||
@@ -255,13 +254,12 @@ def curate_from_google_trends(geo_list=['US']):
|
|||||||
attempts += 1
|
attempts += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords)
|
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords, main_topic)
|
||||||
if not image_url:
|
if not image_url:
|
||||||
image_url, image_source, uploader, page_url = get_image(image_query)
|
image_url, image_source, uploader, page_url = get_image(image_query)
|
||||||
|
|
||||||
hook = get_dynamic_hook(post_data["title"]).strip()
|
hook = get_dynamic_hook(post_data["title"]).strip()
|
||||||
|
|
||||||
# Generate viral share prompt
|
|
||||||
share_prompt = get_viral_share_prompt(post_data["title"], final_summary)
|
share_prompt = get_viral_share_prompt(post_data["title"], final_summary)
|
||||||
share_links_template = (
|
share_links_template = (
|
||||||
f'<p>{share_prompt} '
|
f'<p>{share_prompt} '
|
||||||
|
|||||||
@@ -274,7 +274,6 @@ def curate_from_reddit():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
top_comments = get_top_comments(link, reddit, limit=3)
|
top_comments = get_top_comments(link, reddit, limit=3)
|
||||||
# Fetch additional context via DDG
|
|
||||||
ddg_context = fetch_duckduckgo_news_context(title)
|
ddg_context = fetch_duckduckgo_news_context(title)
|
||||||
content_to_summarize = f"{title}\n\n{summary}\n\nTop Comments:\n{'\n'.join(top_comments) if top_comments else 'None'}\n\nAdditional Context: {ddg_context}"
|
content_to_summarize = f"{title}\n\n{summary}\n\nTop Comments:\n{'\n'.join(top_comments) if top_comments else 'None'}\n\nAdditional Context: {ddg_context}"
|
||||||
interest_score = is_interesting_reddit(
|
interest_score = is_interesting_reddit(
|
||||||
@@ -316,18 +315,17 @@ def curate_from_reddit():
|
|||||||
|
|
||||||
final_summary = insert_link_naturally(final_summary, source_name, link)
|
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)
|
post_data, author, category, image_url, image_source, uploader, pixabay_url = prepare_post_data(final_summary, title, main_topic)
|
||||||
if not post_data:
|
if not post_data:
|
||||||
attempts += 1
|
attempts += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords)
|
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords, main_topic)
|
||||||
if not image_url:
|
if not image_url:
|
||||||
image_url, image_source, uploader, page_url = get_image(image_query)
|
image_url, image_source, uploader, page_url = get_image(image_query)
|
||||||
|
|
||||||
hook = get_dynamic_hook(post_data["title"]).strip()
|
hook = get_dynamic_hook(post_data["title"]).strip()
|
||||||
|
|
||||||
# Generate viral share prompt
|
|
||||||
share_prompt = get_viral_share_prompt(post_data["title"], final_summary)
|
share_prompt = get_viral_share_prompt(post_data["title"], final_summary)
|
||||||
share_links_template = (
|
share_links_template = (
|
||||||
f'<p>{share_prompt} '
|
f'<p>{share_prompt} '
|
||||||
|
|||||||
+10
-25
@@ -210,7 +210,7 @@ def fetch_duckduckgo_news_context(title, hours=24):
|
|||||||
return title
|
return title
|
||||||
|
|
||||||
def curate_from_rss():
|
def curate_from_rss():
|
||||||
articles = fetch_rss_feeds()
|
articles = fetch_rss_articles()
|
||||||
if not articles:
|
if not articles:
|
||||||
print("No RSS articles available")
|
print("No RSS articles available")
|
||||||
logging.info("No RSS articles available")
|
logging.info("No RSS articles available")
|
||||||
@@ -222,9 +222,8 @@ def curate_from_rss():
|
|||||||
article = articles.pop(0)
|
article = articles.pop(0)
|
||||||
title = article["title"]
|
title = article["title"]
|
||||||
link = article["link"]
|
link = article["link"]
|
||||||
summary = article["summary"]
|
summary = article.get("summary", "")
|
||||||
content = article["content"]
|
source_name = article.get("source_name", "Unknown Source")
|
||||||
source_name = article["feed_title"]
|
|
||||||
original_source = f'<a href="{link}">{source_name}</a>'
|
original_source = f'<a href="{link}">{source_name}</a>'
|
||||||
|
|
||||||
if title in posted_titles:
|
if title in posted_titles:
|
||||||
@@ -243,17 +242,11 @@ def curate_from_rss():
|
|||||||
attempts += 1
|
attempts += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Pass main_topic to get_flickr_image for use in fallbacks
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Fetch additional context via DDG
|
|
||||||
ddg_context = fetch_duckduckgo_news_context(title)
|
ddg_context = fetch_duckduckgo_news_context(title)
|
||||||
scoring_content = f"{title}\n\n{summary}\n\nContent: {content}\n\nAdditional Context: {ddg_context}"
|
scoring_content = f"{title}\n\n{summary}\n\nAdditional Context: {ddg_context}"
|
||||||
interest_score = is_interesting(scoring_content)
|
interest_score = is_interesting(scoring_content)
|
||||||
logging.info(f"Interest score for '{title}': {interest_score}")
|
logging.info(f"Interest score for '{title}': {interest_score}")
|
||||||
if interest_score < 7:
|
if interest_score < 6:
|
||||||
print(f"RSS Interest Too Low: {interest_score}")
|
print(f"RSS Interest Too Low: {interest_score}")
|
||||||
logging.info(f"RSS Interest Too Low: {interest_score}")
|
logging.info(f"RSS Interest Too Low: {interest_score}")
|
||||||
attempts += 1
|
attempts += 1
|
||||||
@@ -265,7 +258,7 @@ def curate_from_rss():
|
|||||||
f"FOCUS: Summarize ONLY the provided content, focusing on its specific topic and details without mentioning the original title.\n"
|
f"FOCUS: Summarize ONLY the provided content, focusing on its specific topic and details without mentioning the original title.\n"
|
||||||
f"Incorporate relevant insights from this additional context if available: {ddg_context}.\n"
|
f"Incorporate relevant insights from this additional context if available: {ddg_context}.\n"
|
||||||
f"Do NOT introduce unrelated concepts unless in the content or additional context.\n"
|
f"Do NOT introduce unrelated concepts unless in the content or additional context.\n"
|
||||||
f"Expand on the core idea with relevant context about its appeal or significance.\n"
|
f"Expand on the core idea with relevant context about its appeal or significance in food trends.\n"
|
||||||
f"Do not include emojis in the summary."
|
f"Do not include emojis in the summary."
|
||||||
)
|
)
|
||||||
content_to_summarize = scoring_content
|
content_to_summarize = scoring_content
|
||||||
@@ -282,32 +275,25 @@ def curate_from_rss():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
final_summary = insert_link_naturally(final_summary, source_name, link)
|
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, main_topic)
|
post_data, author, category, image_url, image_source, uploader, pixabay_url = prepare_post_data(final_summary, title, main_topic)
|
||||||
if not post_data:
|
if not post_data:
|
||||||
logging.info(f"Post data preparation failed for '{title}'")
|
|
||||||
attempts += 1
|
attempts += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Fetch image
|
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords, main_topic)
|
||||||
image_url, image_source, uploader, page_url = get_flickr_image(image_query, relevance_keywords)
|
|
||||||
if not image_url:
|
if not image_url:
|
||||||
logging.info(f"Flickr fetch failed for '{image_query}'. Falling back to Pixabay.")
|
|
||||||
image_url, image_source, uploader, page_url = get_image(image_query)
|
image_url, image_source, uploader, page_url = get_image(image_query)
|
||||||
if not image_url:
|
|
||||||
logging.info(f"Pixabay fetch failed for '{image_query}'. Skipping article '{title}'.")
|
|
||||||
attempts += 1
|
|
||||||
continue
|
|
||||||
|
|
||||||
hook = get_dynamic_hook(post_data["title"]).strip()
|
hook = get_dynamic_hook(post_data["title"]).strip()
|
||||||
|
|
||||||
# Generate viral share prompt
|
|
||||||
share_prompt = get_viral_share_prompt(post_data["title"], final_summary)
|
share_prompt = get_viral_share_prompt(post_data["title"], final_summary)
|
||||||
share_links_template = (
|
share_links_template = (
|
||||||
f'<p>{share_prompt} '
|
f'<p>{share_prompt} '
|
||||||
f'<a href="https://x.com/intent/tweet?url={{post_url}}&text={{share_text}}" target="_blank"><i class="tsi tsi-twitter"></i></a> '
|
f'<a href="https://x.com/intent/tweet?url={{post_url}}&text={{share_text}}" target="_blank"><i class="tsi tsi-twitter"></i></a> '
|
||||||
f'<a href="https://www.facebook.com/sharer/sharer.php?u={{post_url}}" target="_blank"><i class="tsi tsi-facebook"></i></a></p>'
|
f'<a href="https://www.facebook.com/sharer/sharer.php?u={{post_url}}" target="_blank"><i class="tsi tsi-facebook"></i></a></p>'
|
||||||
)
|
)
|
||||||
post_data["content"] = f"{final_summary}\n\n{share_links_template}" # Removed cta from content
|
post_data["content"] = f"{final_summary}\n\n{share_links_template}"
|
||||||
|
|
||||||
global is_posting
|
global is_posting
|
||||||
is_posting = True
|
is_posting = True
|
||||||
@@ -333,8 +319,7 @@ def curate_from_rss():
|
|||||||
share_text_encoded = quote(share_text)
|
share_text_encoded = quote(share_text)
|
||||||
post_url_encoded = quote(post_url)
|
post_url_encoded = quote(post_url)
|
||||||
share_links = share_links_template.format(post_url=post_url_encoded, share_text=share_text_encoded)
|
share_links = share_links_template.format(post_url=post_url_encoded, share_text=share_text_encoded)
|
||||||
# Removed: cta = select_best_cta(post_data["title"], final_summary, post_url=post_url)
|
post_data["content"] = f"{final_summary}\n\n{share_links}"
|
||||||
post_data["content"] = f"{final_summary}\n\n{share_links}" # Removed cta from content
|
|
||||||
is_posting = True
|
is_posting = True
|
||||||
try:
|
try:
|
||||||
post_to_wp(
|
post_to_wp(
|
||||||
|
|||||||
Reference in New Issue
Block a user