add check once for rate limiting X
This commit is contained in:
+12
-3
@@ -109,6 +109,9 @@ def setup_logging():
|
||||
# Call setup_logging immediately
|
||||
setup_logging()
|
||||
|
||||
check_author_rate_limit.script_run_id = int(time.time())
|
||||
logging.info(f"Set script_run_id to {check_author_rate_limit.script_run_id}")
|
||||
|
||||
posted_titles_data = load_json_file(POSTED_TITLES_FILE, EXPIRATION_HOURS)
|
||||
posted_titles = set(entry["title"] for entry in posted_titles_data)
|
||||
used_images = set(entry["title"] for entry in load_json_file(USED_IMAGES_FILE, IMAGE_EXPIRATION_DAYS) if "title" in entry)
|
||||
@@ -417,7 +420,9 @@ 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 *****")
|
||||
return post_data, category, random.randint(0, 1800)
|
||||
# Sleep for 20 to 30 minutes (1200 to 1800 seconds)
|
||||
sleep_time = random.randint(1200, 1800)
|
||||
return post_data, category, sleep_time
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to post to WordPress for '{title}': {e}", exc_info=True)
|
||||
@@ -435,10 +440,14 @@ 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")
|
||||
return None, None, random.randint(600, 1800)
|
||||
# Sleep for 20 to 30 minutes (1200 to 1800 seconds)
|
||||
sleep_time = random.randint(1200, 1800)
|
||||
return None, None, sleep_time
|
||||
except Exception as e:
|
||||
logging.error(f"Unexpected error in curate_from_rss: {e}", exc_info=True)
|
||||
return None, None, random.randint(600, 1800)
|
||||
# Sleep for 20 to 30 minutes (1200 to 1800 seconds)
|
||||
sleep_time = random.randint(1200, 1800)
|
||||
return None, None, sleep_time
|
||||
|
||||
def run_rss_automator():
|
||||
lock_fd = None
|
||||
|
||||
Reference in New Issue
Block a user