|
|
|
@ -28,7 +28,7 @@ from foodie_utils import ( |
|
|
|
is_interesting, generate_title_from_summary, summarize_with_gpt4o, |
|
|
|
is_interesting, generate_title_from_summary, summarize_with_gpt4o, |
|
|
|
generate_category_from_summary, post_to_wp, prepare_post_data, |
|
|
|
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, |
|
|
|
get_next_author_round_robin, check_author_rate_limit |
|
|
|
get_next_author_round_robin, check_author_rate_limit, update_system_activity |
|
|
|
) |
|
|
|
) |
|
|
|
from foodie_hooks import get_dynamic_hook, get_viral_share_prompt |
|
|
|
from foodie_hooks import get_dynamic_hook, get_viral_share_prompt |
|
|
|
from dotenv import load_dotenv |
|
|
|
from dotenv import load_dotenv |
|
|
|
@ -452,6 +452,55 @@ def curate_from_google_trends(posted_titles_data, posted_titles, used_images_dat |
|
|
|
logging.error(f"Unexpected error in curate_from_google_trends: {e}", exc_info=True) |
|
|
|
logging.error(f"Unexpected error in curate_from_google_trends: {e}", exc_info=True) |
|
|
|
return None, None, False |
|
|
|
return None, None, False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# System Activity Tracking |
|
|
|
|
|
|
|
def update_system_activity(script_name, status, pid=None): |
|
|
|
|
|
|
|
"""Update the system activity JSON file with the script's status.""" |
|
|
|
|
|
|
|
activity_file = "/home/shane/foodie_automator/system_activity.json" |
|
|
|
|
|
|
|
activity_data = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Load existing data |
|
|
|
|
|
|
|
if os.path.exists(activity_file): |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
with open(activity_file, 'r') as f: |
|
|
|
|
|
|
|
activity_data = json.load(f) |
|
|
|
|
|
|
|
except json.JSONDecodeError: |
|
|
|
|
|
|
|
logging.error("Corrupted system_activity.json, resetting to empty list") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Find or create entry for the script |
|
|
|
|
|
|
|
script_entry = next((entry for entry in activity_data if entry["script_name"] == script_name), None) |
|
|
|
|
|
|
|
if not script_entry: |
|
|
|
|
|
|
|
script_entry = { |
|
|
|
|
|
|
|
"script_name": script_name, |
|
|
|
|
|
|
|
"pid": None, |
|
|
|
|
|
|
|
"start_time": None, |
|
|
|
|
|
|
|
"stop_time": None, |
|
|
|
|
|
|
|
"status": "stopped" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
activity_data.append(script_entry) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Update the entry |
|
|
|
|
|
|
|
if status == "running": |
|
|
|
|
|
|
|
script_entry.update({ |
|
|
|
|
|
|
|
"pid": pid, |
|
|
|
|
|
|
|
"start_time": datetime.now(timezone.utc).isoformat(), |
|
|
|
|
|
|
|
"stop_time": None, |
|
|
|
|
|
|
|
"status": "running" |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
elif status == "stopped": |
|
|
|
|
|
|
|
script_entry.update({ |
|
|
|
|
|
|
|
"pid": None, |
|
|
|
|
|
|
|
"stop_time": datetime.now(timezone.utc).isoformat(), |
|
|
|
|
|
|
|
"status": "stopped" |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Save updated data |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
with open(activity_file, 'w') as f: |
|
|
|
|
|
|
|
json.dump(activity_data, f, indent=2) |
|
|
|
|
|
|
|
logging.info(f"Updated system activity: {script_name} is {status}") |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
|
|
logging.error(f"Failed to update system_activity.json: {e}") |
|
|
|
|
|
|
|
|
|
|
|
def run_google_trends_automator(): |
|
|
|
def run_google_trends_automator(): |
|
|
|
lock_fd = None |
|
|
|
lock_fd = None |
|
|
|
try: |
|
|
|
try: |
|
|
|
|