diff --git a/mirror-yt.py b/mirror-yt.py index 8feac33..20dfa68 100644 --- a/mirror-yt.py +++ b/mirror-yt.py @@ -11,8 +11,10 @@ import click help='Error out if one of the directories from the given list does not exist') @click.option('--base-dir', type=Path, default='.', show_default=True, 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.argument('CHANNEL_FILE', required=True) -def download(allow_unknown, base_dir, channel_file): +def download(allow_unknown, base_dir, max_video_height, 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. @@ -58,8 +60,11 @@ def download(allow_unknown, base_dir, channel_file): '--download-archive', target_dir / '.archive', '--break-on-existing', '--write-thumbnail', - url + '--embed-thumbnail', ] + if max_video_height: + cmd.extend(['-f', f"bv*[height<={max_video_height}]+ba"]) + cmd.append(url) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=target_dir) prev_output = '' while p.poll() is None: