mirror-yt: Update output name format
We add the video height to the output file name if it's given. We also add the playlist_index as a prefix, if the user requests this. This is most likely a good idea, because videos uploaded on the same day can otherwise be in another order than intended. This is most likely not backwards compatible so already-downloaded channels should not use this.
This commit is contained in:
parent
0ba42bb039
commit
43f12decea
14
mirror-yt.py
14
mirror-yt.py
|
@ -17,8 +17,10 @@ import click
|
||||||
help="Minimum sleep interval between downloads")
|
help="Minimum sleep interval between downloads")
|
||||||
@click.option('--max-sleep-interval', type=int, default=300, show_default=True,
|
@click.option('--max-sleep-interval', type=int, default=300, show_default=True,
|
||||||
help="Maximum sleep interval between downloads (see also --sleep-interval")
|
help="Maximum sleep interval between downloads (see also --sleep-interval")
|
||||||
|
@click.option('--with-playlist-index', is_flag=True, help="Prepend the playlist index to the output file name")
|
||||||
@click.argument('CHANNEL_FILE', required=True)
|
@click.argument('CHANNEL_FILE', required=True)
|
||||||
def download(allow_unknown, base_dir, max_video_height, sleep_interval, max_sleep_interval, channel_file):
|
def download(allow_unknown, base_dir, max_video_height, sleep_interval, max_sleep_interval, with_playlist_index,
|
||||||
|
channel_file):
|
||||||
"""Mirror channels from YouTube
|
"""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.
|
The list of channels needs to be provided via CHANNEL_FILE. The format of the file should be one channel per line.
|
||||||
|
@ -56,9 +58,17 @@ def download(allow_unknown, base_dir, max_video_height, sleep_interval, max_slee
|
||||||
if not target_dir.exists():
|
if not target_dir.exists():
|
||||||
target_dir.mkdir()
|
target_dir.mkdir()
|
||||||
|
|
||||||
|
# NOTE: Using %(formats.:.height)s doesn't work, because the
|
||||||
|
# thumbnail doesn't take it's own output template even when
|
||||||
|
# provided with -o 'thumbnail:…'
|
||||||
|
name_fmt = '%(upload_date)s - %(title)s - %(id)s{}.%(ext)s'.format(
|
||||||
|
f" - {max_video_height}" if max_video_height else '')
|
||||||
|
if with_playlist_index:
|
||||||
|
name_fmt = f"%(playlist_index)s - {name_fmt}"
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
'yt-dlp',
|
'yt-dlp',
|
||||||
'-o', '%(upload_date)s - %(title)s - %(id)s.%(ext)s',
|
'-o', name_fmt,
|
||||||
'--sleep-interval', str(sleep_interval),
|
'--sleep-interval', str(sleep_interval),
|
||||||
'--max-sleep-interval', str(max_sleep_interval),
|
'--max-sleep-interval', str(max_sleep_interval),
|
||||||
'--download-archive', target_dir / '.archive',
|
'--download-archive', target_dir / '.archive',
|
||||||
|
|
Loading…
Reference in New Issue