Youtube-dl Batch Download

0 views
Skip to first unread message

Carlita Pourier

unread,
Jan 7, 2024, 12:21:12 AM1/7/24
to foyfortewatch
I use youtube-dl to download files from YouTube. I have tried downloading multiple files, but it is not working out for me. I have to open multiple terminals and start afresh every time I want to download a video.
youtube-dl batch download
First create a batch file which is a text file containing a list of URLs of videos from YouTube that you want to download. The URLs should be arranged in a list having only one URL and nothing else on each line, with a new line for each URL in the list. Save the batch file with a name that is easy to remember like batch-file.txt. If the multiple files are all on the same playlist, channel or user webpage in YouTube, you can generate a text file with a list that has all the links on that page by running the following command:
youtube-dl -cit --format=mp4 --batch-file=./list-of-youtube-videos-link.txt was what worked for me combining and solutions. I'm recording it here standalone rather than scroll multiple answers again in future.
I'm using youtube-dl to extract the best possible audio quality from youtube videos. However the best quality audio usually turns out to be the webm format, which isn't useful. I would like to write a batch script that converts the webm file to an mp3 with ffmpeg. I've already tried using this guide on reddit to do it, but it doesn't seem to work. It appears to create an empty mp3 file that displays an error when i try to play it and the meta data is also completly blank.
The idea is, is that you use youtube-dl to extract the best possible audio, then put that file into the Downloaded folder (see pic below) and then you run the mp3 script (which uses commands from ffmpeg) to convert the webm file in the Downloaded folder to a mp3 file, and place it in the Converted folder. The mp3 script is the code above. But it doesn't seem to work properly.
If you added -f bestaudio option to the commandyoutube-dl -x --audio-format mp3 =BaW_jenozKc ,it would first download the best audio from youtube, and then convert it to mp3 without needing an ffmpeg bash script.
I am using youtube-dl on windows (youtube-dl.exe)Downloading the video works great and also just the audio. But what i want is for it to save the audio file in a different place eg. C:\Users*******\Desktop
The character % has a special meaning in batch files as it marks the beginning and end of an immediately expanded environment variable reference or a batch file argument reference or a loop variable reference. The percent sign must be escaped with one more % to specify a literally interpreted % character.
Then the current directory is changed to the Desktop directory of the currently used user account independent from which drive the batch file was started. Run in command prompt window cd /? for details about this command and its options.
The line with youtube-dl.exe is changed as now the executable is called with full path (as current working directory is now the user's Desktop directory). Also the output directory is enclosed now in double quotes, uses also environment variable USERPROFILE, has escaped the single percent sign with one more % and the URL is referenced now in double quotes using delayed expansion (exclamation marks instead of percent signs). Run in a command prompt window set /? for help and details about delayed expansion.
The command ENDLOCAL results in discarding the local copy of the table with the environment variables (ToolPath is not defined anymore after this line and all changes on other variables are lost), restores previous values for delayed expansion (most likely turning it off as not enabled by default) and command extensions (most likely being still enabled as by default) and also restoring previous working directory (most likely the path of the batch file if started with a double click).
What I do now is call a .bat file on a schedule basis with all my arguments, naming structures, archives, etc. So it's fairly automated except that I would have to download a newer youtube-dl version manually
Alternatively, I've come around this and this but I wouldn't know how to setup or if it could manage to handle my script. So I was thinking... is there a way that I could have unraid read my batch files on a regular basis and run youtube-dl? Much like I do right now on windows
tl;dr youtube-dl docker containers I tested can't handle some or all my output arguments for channels I regularly download to archive. is there a way to make unraid call a batch file (or similar) on a schedule basis and run youtube-dl to download newly added videos that are not listed in its output archive?
You can use the User.Scripts plugin to run a bash script on a schedule. So far as running youtube-dl specifically the best way is within a docker container. You would use a docker run command in your script (probably with the --rm option to delete the container when done) to launch a youtubedl container from your script. Depending on the image you choose you may need to override the container entrypoint to directly launch youtubedl and then your would pass your arguments in the docker cmd.
I may be going about this the wrong way but I have a Debian VM in unraid always running that even on my underpowered board uses barely any CPU (
You have a lot of options when it comes to downloading YouTube videos or videos from other video sites. One of the most advanced programs for that kind of task is youtube-dl. Since it is a command line program, it may not be the first choice for users who don't feel comfortable running commands on the command line.
While that is understandable, especially for single videos that you may want to download, you may miss out on one of the best tools that is available today. One of youtube-dl's strengths is the ability to download multiple videos from all supported sites.
Before you can start using youtube-dl, you need to download the tool to your device. Instructions in this guide focus on the Windows version, but youtube-dl is also available for other operating systems.
If you want to download multiple video files that are not related to each other, e.g. from a single playlist file or channel, you may use a text file with video URLs to download the videos using youtube-dl. Just create a new text file, name it downloads.txt, and add one YouTube video URL per line to it.
Downloading videos from a playlist works similarly. Just replace the channel URL from the example above with a playlist URL, and youtube-dl will download all the linked videos from the specified playlist.
Remember that a copyright-enforcement organization (the RIAA, I think) succeeded in getting Microsoft to pull youtube-dl from GitHub a few years back based on a claim that it was a copyright-infringement tool. There was an uproar from journalists, lawyers, academics, and others who rely heavily on fair use, and youtube-dl was reinstated on GitHub within a couple/few weeks. Bottom Line: Tools like youtube-dl have legitimate, legal uses, and those uses are very important to a free, open, democratic society.
I wonder, considering the amount of attention the project has received in the last year or so, if someone has *paid* the developer(s) of youtube-dl off to halt development and let it *rot on the vine*?
Run the capture-video script from the command line, providing a name and url to capture, each surrounded by double-quotes.C:\Programs\capture> capture-video.bat "Franzoli Electronics" " =Uf3ouaeB6UQ"youtube-dl is up-to-date (2021.06.06)[youtube] Uf3ouaeB6UQ: Downloading webpage[youtube] Uf3ouaeB6UQ: Downloading player a7cbbf24[download] Destination: Never Gonna SHOCK You Up-Uf3ouaeB6UQ.mp4[download] 100% of 29.24MiB in 00:05[ffmpeg] Not converting video file Never Gonna SHOCK You Up-Uf3ouaeB6UQ.mp4 - already is in target format mp4
Run the capture-audio script from the command line, providing a name and url to capture, each surrounded by double-quotes.C:\Programs\capture> capture-audio.bat "Franzoli Electronics" " =Uf3ouaeB6UQ"youtube-dl is up-to-date (2021.06.06)[youtube] Uf3ouaeB6UQ: Downloading webpage[youtube] Uf3ouaeB6UQ: Downloading player 2a6f5e06[download] Destination: Never Gonna SHOCK You Up-Uf3ouaeB6UQ.webm[download] 100% of 1.94MiB in 00:00[ffmpeg] Destination: Never Gonna SHOCK You Up-Uf3ouaeB6UQ.mp3Deleting original file Never Gonna SHOCK You Up-Uf3ouaeB6UQ.webm (pass -k to keep)
Use this to avoid re-downloading already grabbed content. Each successful download gets noted in the file so youtube-dl will skip them the next time. This setting is essential if you want to update your archive periodically. The archive file will reside in your YouTube folder and will serve as a log or history for every download you perform, on any channel.
See? Much nicer! Use this snippet as a template to create a batch file for every YouTube channel you want to download. Then you can run these jobs individually or even schedule them (see later).
The batch files for downloading a channel are in a way that they work with both manual and automatic start. This part of the guide assumes they already work for you, the initial run is complete, and every video from said channels have been downloaded. Therefore, you are only waiting for new videos.
That simple command says: Use youtube-dl to download the video at the URL in an MP4 format. You could also use -f webm for the WebM version (usually for the 4K versions) or even -f mp3 to just grab the audio. That will download to your Home folder by default Macintosh HD/Users/USERNAME/
35fe9a5643
Reply all
Reply to author
Forward
0 new messages