From 0ba42bb039c41a27a3b14d3a6f27656283d98841 Mon Sep 17 00:00:00 2001 From: MasterofJOKers Date: Tue, 30 Sep 2025 18:52:47 +0200 Subject: [PATCH] mirror-yt: Support setting sleep intervals If the user wants to download videos a little faster than default, they should be able to influence the between-downloads sleep interval. --- mirror-yt.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mirror-yt.py b/mirror-yt.py index 20dfa68..25c8a55 100644 --- a/mirror-yt.py +++ b/mirror-yt.py @@ -13,8 +13,12 @@ import click help='Base directory where the channel directories get created') @click.option('--max-video-height', type=int, help='Maximum height of the video e.g. 720 or 1080 to filter video formats by') +@click.option('--sleep-interval', type=int, default=30, show_default=True, + help="Minimum sleep interval between downloads") +@click.option('--max-sleep-interval', type=int, default=300, show_default=True, + help="Maximum sleep interval between downloads (see also --sleep-interval") @click.argument('CHANNEL_FILE', required=True) -def download(allow_unknown, base_dir, max_video_height, channel_file): +def download(allow_unknown, base_dir, max_video_height, sleep_interval, max_sleep_interval, channel_file): """Mirror channels from YouTube The list of channels needs to be provided via CHANNEL_FILE. The format of the file should be one channel per line. @@ -55,8 +59,8 @@ def download(allow_unknown, base_dir, max_video_height, channel_file): cmd = [ 'yt-dlp', '-o', '%(upload_date)s - %(title)s - %(id)s.%(ext)s', - '--sleep-interval', '30', - '--max-sleep-interval', '300', + '--sleep-interval', str(sleep_interval), + '--max-sleep-interval', str(max_sleep_interval), '--download-archive', target_dir / '.archive', '--break-on-existing', '--write-thumbnail',