Fix: Implement minimum polling interval to conserve YouTube API quota.
This commit is contained in:
4
main.py
4
main.py
@@ -162,7 +162,9 @@ def main():
|
||||
|
||||
next_page_token = response.get('nextPageToken')
|
||||
polling_interval_millis = response['pollingIntervalMillis']
|
||||
time.sleep(polling_interval_millis / 1000.0)
|
||||
# Ensure a minimum sleep duration to conserve API quota
|
||||
sleep_time = max(5, polling_interval_millis / 1000.0)
|
||||
time.sleep(sleep_time)
|
||||
else:
|
||||
console.print("[yellow]No new messages or an error occurred. Retrying...[/yellow]")
|
||||
time.sleep(5) # Wait 5 seconds before retrying on error
|
||||
|
||||
Reference in New Issue
Block a user