use file instead of API checks for rate limit X
This commit is contained in:
+8
-3
@@ -3,7 +3,7 @@ import logging
|
||||
from datetime import datetime, timezone
|
||||
from foodie_utils import (
|
||||
AUTHORS, check_author_rate_limit, load_json_file,
|
||||
get_x_rate_limit_status, update_system_activity
|
||||
get_x_rate_limit_status, update_system_activity, is_any_script_running
|
||||
)
|
||||
import time
|
||||
import sys
|
||||
@@ -22,7 +22,8 @@ def display_author_status(author):
|
||||
can_post, remaining, reset = check_author_rate_limit(author)
|
||||
reset_time = datetime.fromtimestamp(reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# Get detailed API status first
|
||||
# Only check API if no scripts are running
|
||||
if not is_any_script_running():
|
||||
api_remaining, api_reset = get_x_rate_limit_status(author)
|
||||
if api_remaining is not None:
|
||||
api_reset_time = datetime.fromtimestamp(api_reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||
@@ -38,7 +39,10 @@ def display_author_status(author):
|
||||
print(f" • Can post: {'Yes' if can_post else 'No'}")
|
||||
|
||||
# Show API status for verification
|
||||
if not is_any_script_running():
|
||||
api_remaining, api_reset = get_x_rate_limit_status(author)
|
||||
if api_remaining is not None:
|
||||
api_reset_time = datetime.fromtimestamp(api_reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||
print(f" • API Status: {api_remaining} remaining, resets at {api_reset_time}")
|
||||
|
||||
def display_total_capacity():
|
||||
@@ -53,7 +57,8 @@ def display_total_capacity():
|
||||
|
||||
for author in AUTHORS:
|
||||
can_post, remaining, _ = check_author_rate_limit(author)
|
||||
# Get API status for accurate count
|
||||
# Only check API if no scripts are running
|
||||
if not is_any_script_running():
|
||||
api_remaining, _ = get_x_rate_limit_status(author)
|
||||
if api_remaining is not None:
|
||||
remaining = api_remaining
|
||||
|
||||
Reference in New Issue
Block a user