From 16de972f7b15cab253fbca77e7a1f9517d179eea Mon Sep 17 00:00:00 2001 From: MasterofJOKers Date: Sun, 21 Apr 2024 23:18:19 +0200 Subject: [PATCH] mirror-yt: Add a sleep between downloads We want to play nice in the internet. --- mirror-yt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mirror-yt.py b/mirror-yt.py index 6601edb..128e522 100644 --- a/mirror-yt.py +++ b/mirror-yt.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from pathlib import Path import subprocess +import time import click @@ -25,7 +26,7 @@ def download(allow_unknown, base_dir, channel_file): line = line.strip() if line.startswith('#'): continue - + dir_name, url = line.split(';') channels[dir_name] = url @@ -61,6 +62,10 @@ def download(allow_unknown, base_dir, channel_file): ] subprocess.run(cmd, check=True, cwd=target_dir) + sleep_seconds = 5 + print(f"Sleeping {sleep_seconds}s") + time.sleep(sleep_seconds) + if __name__ == '__main__': download()