Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
[Feature Request] parallel downloads feature using a batch file #3746
Comments
|
This would be nice for playlists for example at Youtube, too :) |
|
|
|
Is there any reason why |
Some cases: custom output templates, postprocessing... |
|
I would rather have the complexity of parallel downloads kept out of youtube-dl so that its code base remains more maintainable. Parallelism can be already be delegated to
Maybe I'm missing something but why can't this be done with |
|
From the viewpoint of youtube-dl internals, a series of urls is not different than a playlist with several videos. I was considering the latter case when I wrote the previous comment. If you want to achieve downloading videos of a playlist in parallel along with postprocessing them, you'll need to run the parallel download step - either via internal codes or external tools - from youtube-dl, instead of run youtube-dl in parallel, and then the postprocessing step can continue inside youtube-dl. Or moving postprocessing codes to standalone commands. That would be interesting. |
|
After bit of research and all,I found out that https://github.com/MrS0m30n3/youtube-dl-gui already does supports it in series form,tinkering of it can support the parallel form https://pypi.python.org/pypi/twodict may help. https://github.com/MrS0m30n3/youtube-dl-gui/blob/master/youtube_dl_gui/downloadmanager.py#L106-L122 manages the current state. https://github.com/MrS0m30n3/youtube-dl-gui/blob/master/youtube_dl_gui/downloadmanager.py#L239-L385 manages the queue which can be modified to work in parallel. So it seems the process already exist so a little tinkering will add to the main project. |
If you use xargs, it's nontrivial to include the numerical playlist index in the filename (for playlists where order matters). |
|
@siddht4 get the download data using youtube-dl ( For example, aria2 with |
|
Just wanted to thank @Roman2K and provide the full one-liner, since many youtube-dl users may not be familiar with xargs or the shell.
|
|
@alex-hofmann can this be used to download in parallel when downloading a channel or playlist on youtube? |
|
@aryehbeitz No, I guess. It only allows you to download multiple links in parallel, but you need to specify those links in the file. Playlists and channels are just single link which are passed to youtube-dl as you normally do, so it does not solve the problem of this issue. If there's a way to gather all the links from one playlist and place them into the file, this would do the trick. |
|
@aryehbeitz @PiotrDabrowskey Yeah I think you're right, this is only useful when you can feed the known links. For example, if someone wanted to download the Jeopardy! episodes that a reddit user graciously uploads daily they could use something like curl -A 'random' https://www.reddit.com/user/jibjabjrjr/.rss 2>/dev/null | grep -Po 'https:\/\/drive.*?(?=\;|\&)' | xargs -n 1 -P 4 youtube-dlMy guess is that something similar is available for pulling the urls from a youtube playlist with a little curl+grep |
|
@aryehbeitz You can get the individual URLs from a playlist with: $ youtube-dl -j --flat-playlist 'https://www.youtube.com/watch?v=CcNo07Xp8aQ&list=PLA671B7E7BFB780B7' | jq -r '"https://youtu.be/"+ .url'That can be fed directly to |
|
If anyone's interested, I made a cronjob for backing up my YouTube playlists to Google Drive (using rclone). Idempotent/incremental. Kind of rough scripting but I've been running it with several 500+ long playlists over the last few days and it works well. https://github.com/Roman2K/ytdump
Clone and customize to your needs. |
|
Based on @alex-hofmann's and @Roman2K's hints, here's a trashman's oneliner that should work with any extractor (requires
Adjust to your heart's content. |
|
@zer0def Nice! Small issue: the number of parallel downloaders is set to the number of CPU cores (-P`nproc`). That parameter should be tuned to match the network capacity, not the CPU capacity. Anyone who wants to try that should start it around -P5, and increase it until it saturates their connection. |
|
@epitron As long as your extractions don't fall back to ffmpeg, it's safe to ramp up the process number, but when they do, you might end up unnecessarily extending your downloads due to threads fighting for CPU time, so I've picked As per my previous comment: adjust to your heart's content, since everyone's case might be different. |
|
@zer0def Hyperthreading can also artificially increase your CPU count. What if you have 32 cores, and a regular network connection? I thought YTDL only used ffmpeg to copy streams into different containers (unless you pass |
|
Then you have threads stalling for data, which is hardly a concern compared to saturating out low-end and/or low-core count CPUs with a pipe huge enough to overwhelm it. |
|
@zer0def What if YouTube bans or throttles you for spamming their servers with connections? |
|
Do you have an actual case to provide as basis or are we just talking hypotheses? Because if you're looking for a golden mean, then yes, you could just cobble up a proper solution, write a wrapper script or use |
Is there a way to enable parallel download session fed in by a --batch-file.
Some sites have very slow band width per video, therefore instead of waiting to finish previous file, it is much efficient to run parallel downloads.