dynamic sleep

This commit is contained in:
Simon
2025-01-03 11:41:55 +07:00
parent 490b61961a
commit 2dbce9da4d
5 changed files with 23 additions and 7 deletions

View File

@@ -40,6 +40,18 @@ def randomizor(length: int) -> str:
return "".join(random.choice(pool) for i in range(length))
def get_sleep(config) -> int:
"""get randomized sleep"""
sleep_config = config["downloads"].get("sleep_interval")
if not sleep_config:
return 0
rand_sleep = random.randrange(
int(sleep_config * 0.5), int(sleep_config * 1.5)
)
return rand_sleep
def requests_headers() -> dict[str, str]:
"""build header with random user agent for requests outside of yt-dlp"""