Skip to content

Instantly share code, notes, and snippets.

@Anon-Exploiter
Last active December 22, 2020 04:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anon-Exploiter/ca3ab8f7a7edee8227622c7a6a97e396 to your computer and use it in GitHub Desktop.
Save Anon-Exploiter/ca3ab8f7a7edee8227622c7a6a97e396 to your computer and use it in GitHub Desktop.
Generating commands for youtube playlist downloading in reverse with index in file name using youtube-dl
import os
playlist = "https://www.youtube.com/user/..."
command = f"youtube-dl -j --flat-playlist --playlist-reverse {playlist} | jq -r '.id' | sed 's_^_https://youtu.be/_'"
output = os.popen(command).read()
print(output)
ytUrls = []
for count, urls in zip(range(1, 1000), output.strip().split("\n")):
count = str(count).zfill(3)
cmd = f'youtube-dl -f mp4 -i -v -R 3 --fragment-retries 3 -c -o "{count} - %(title)s.%(ext)s" {urls} --external-downloader "aria2c" --external-downloader-args "-j 10 -s 10 -x 16 --file-allocation=none -c"'
print(cmd)
@Anon-Exploiter
Copy link
Author

Listing all the video titles in a playlist:

youtube-dl -j --flat-playlist --ignore-errors --playlist-reverse https://www.youtube.com/playlist?list=... | jq -r '.title'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment