fix
This commit is contained in:
+19
-10
@@ -261,7 +261,8 @@ def curate_from_rss(posted_titles_data, posted_titles, used_images_data, used_im
|
||||
articles = fetch_rss_feeds()
|
||||
if not articles:
|
||||
logging.info("No RSS articles available")
|
||||
return None, None, random.randint(600, 1800)
|
||||
sleep_time = random.randint(1200, 1800) # 20–30 minutes
|
||||
return None, None, sleep_time
|
||||
|
||||
attempts = 0
|
||||
max_attempts = 10
|
||||
@@ -419,8 +420,7 @@ def curate_from_rss(posted_titles_data, posted_titles, used_images_data, used_im
|
||||
logging.info(f"Saved image '{image_url}' to {USED_IMAGES_FILE}")
|
||||
|
||||
logging.info(f"***** SUCCESS: Posted '{post_data['title']}' (ID: {post_id or 'N/A'}) from RSS *****")
|
||||
# Sleep for 20 to 30 minutes (1200 to 1800 seconds)
|
||||
sleep_time = random.randint(1200, 1800)
|
||||
sleep_time = random.randint(1200, 1800) # 20–30 minutes
|
||||
return post_data, category, sleep_time
|
||||
|
||||
except Exception as e:
|
||||
@@ -439,13 +439,11 @@ def curate_from_rss(posted_titles_data, posted_titles, used_images_data, used_im
|
||||
is_posting = False
|
||||
|
||||
logging.info("No interesting RSS article found after attempts")
|
||||
# Sleep for 20 to 30 minutes (1200 to 1800 seconds)
|
||||
sleep_time = random.randint(1200, 1800)
|
||||
sleep_time = random.randint(1200, 1800) # 20–30 minutes
|
||||
return None, None, sleep_time
|
||||
except Exception as e:
|
||||
logging.error(f"Unexpected error in curate_from_rss: {e}", exc_info=True)
|
||||
# Sleep for 20 to 30 minutes (1200 to 1800 seconds)
|
||||
sleep_time = random.randint(1200, 1800)
|
||||
sleep_time = random.randint(1200, 1800) # 20–30 minutes
|
||||
return None, None, sleep_time
|
||||
|
||||
def run_rss_automator():
|
||||
@@ -454,13 +452,23 @@ def run_rss_automator():
|
||||
lock_fd = acquire_lock()
|
||||
update_system_activity(SCRIPT_NAME, "running", os.getpid()) # Record start
|
||||
logging.info("***** RSS Automator Launched *****")
|
||||
# ... (rest of the function) ...
|
||||
posted_titles_data = load_json_file(POSTED_TITLES_FILE, EXPIRATION_HOURS)
|
||||
posted_titles = set(entry["title"] for entry in posted_titles_data)
|
||||
used_images_data = load_json_file(USED_IMAGES_FILE, IMAGE_EXPIRATION_DAYS)
|
||||
used_images = set(entry["title"] for entry in used_images_data if "title" in entry)
|
||||
post_data, category, sleep_time = curate_from_rss(posted_titles_data, posted_titles, used_images_data, used_images)
|
||||
if not post_data:
|
||||
logging.info("No postable RSS article found")
|
||||
logging.info("Completed RSS run")
|
||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop
|
||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||
return post_data, category, sleep_time
|
||||
except Exception as e:
|
||||
logging.error(f"Fatal error in run_rss_automator: {e}", exc_info=True)
|
||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop on error
|
||||
return None, None, random.randint(600, 1800)
|
||||
sleep_time = random.randint(1200, 1800) # Fixed to 20–30 minutes
|
||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||
return None, None, sleep_time
|
||||
finally:
|
||||
if lock_fd:
|
||||
fcntl.flock(lock_fd, fcntl.LOCK_UN)
|
||||
@@ -468,4 +476,5 @@ def run_rss_automator():
|
||||
os.remove(LOCK_FILE) if os.path.exists(LOCK_FILE) else None
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_rss_automator()
|
||||
post_data, category, sleep_time = run_rss_automator()
|
||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||
Reference in New Issue
Block a user