Fix: Implement minimum polling interval to conserve YouTube API quota.

This commit is contained in:
2025-10-29 13:12:58 +01:00
parent 01469f9b77
commit d343375790

View File

@@ -162,7 +162,9 @@ def main():
next_page_token = response.get('nextPageToken') next_page_token = response.get('nextPageToken')
polling_interval_millis = response['pollingIntervalMillis'] 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: else:
console.print("[yellow]No new messages or an error occurred. Retrying...[/yellow]") console.print("[yellow]No new messages or an error occurred. Retrying...[/yellow]")
time.sleep(5) # Wait 5 seconds before retrying on error time.sleep(5) # Wait 5 seconds before retrying on error