Youtube-dl Download All Videos From Playlist

0 views
Skip to first unread message

Ayana Hammerschmidt

unread,
Jan 24, 2024, 3:04:50 PM1/24/24
to constubuchsla

to download a playlist from YouTube, but I was wondering if there is a way I can, for example, download videos 2 through 8 (out of a playlist of 10 for example) or the first 5 videos or the last 6 videos or even from video 7 onward?

As I said in the title. I would like to create a playlist on youtube and download the entire thing. I tried searching this sub for an answer but all I found were how to tweak stuff in a more advanced manner. Not how to start doing it. Sorry if this has been posted before.

youtube-dl download all videos from playlist


DOWNLOAD https://t.co/aYzoGGVQjq



But give this one a try if you familiar with the shell and know how to install python and pip on openwrt.
GitHub ytdl-org/youtube-dlCommand-line program to download videos from YouTube.com and other video sites - ytdl-org/youtube-dl

There are in fact web sites and desktop applications that let you download YouTube videos, and some applications allow you to download playlists. So it's possible. Whether it's legal or not, that's another story.

basically what i want to do is watching online videos from the shell via mplayer and elinks w/o downloading them, but not to be limited to youtube, so youtube-viewer is not an option. problem is that mplayer doesn't seem to do the job. some claim you only have to pass an url as an arg for it and that's it.

Pressing a keybind on my computer, dmenu shows up with the playlists and let me pick one to watch. After that, MPV starts the playback on shuffle mode. This is very convenient and much better than browsing YouTube.

I began my downloads this way and found that I really needed to be able to download an entire playlist. Downloading one at a time was time consuming, especially when one playlist had 43 videos. This was going to take a long time. So some more investigation and I found that you can indeed download a playlist.

To download an entire playlist and rename the files to the videos title you can use additional command options for youtube-dl. See the following. This line will download all videos from a specific playlist to a designated folder. It will name the files using the title. youtube-dl -h at the command line for list of options.

I have a small number of content creators that I enjoy following on YouTube, but I fundamentally dislike YouTube's shady algorithms, poor user experience, and invasive ads. These days, most of the content I watch is stored on my Plex server, so I decided to find a way to automatically download and add my favorite YouTube content to my Plex server. After a bit of searching, I found this guide from DIY Futurism which outlined a nice approach to the problem.

My approach is similar, and makes use of the excellent youtube-dl project, along with a personal media scanner and personal media agent for Plex. I run my Plex Media Server on my Synology DS1019+ NAS, which I absolutely adore, so that's where I set everything up. The process was quite simple:

At this point, I was ready to create a script that would download the content and add it to Plex. The key is to take advantage of all of the great features in youtube-dl, including the ability to provide a "batch" file containing target channels, the ability to embed metadata and download thumbnails, and an "archive" feature which tracks what has already been downloaded. My script is a variation on the one from DIY Futurism:

Let's walk through the script. First, I change directories to where I want all of my content downloaded. This is the same directory that I configured in Plex for my "YouTube" library that I created earlier. Next, I specify that I want to process the videos in the playlist chronologically (in "reverse"). I also specify that I only want to download videos that were published in the last two weeks using the --dateafter parameter. You can tweak this to download as much or as little of the content as you'd like.

Next, I point youtube-dl to a text file containing a list of all content that I've already downloaded using the --download-archive parameter, which youtube-dl will automatically maintain for me. Because I am limiting my downloads to the last two weeks, I did need to pre-populate this text file with all of the historical content to avoid having to scan through thousands of videos on each run of the script.

Next, I specify a format for where to store the downloaded content and what to name the files and directories, instruct youtube-dl to embed metadata, and to write a thumbnail image as well. This data will be used by the personal media scanner and agent to help Plex index the content.

#!/bin/bashinput=$1 # get the argument passed to the scriptclean_input="$input/https/http" # youtube-dl doesn't handle https, so convert "https" to "http"url=$(youtube-dl -f140 -g $clean_input) # get the stream url, with the -g option. -f140 is to get the audio onlyclean_url="$url/https/http" # mpd doesn't handle https, so convert "https" to "http"mpc add $clean_url # add the url to the mpc play list

well, I am late, I saved some videos from Utube but they have no sound on the VLC player, so I wanna know Volumio will save me or not? my friend sent me this page -youtube-videos.html but this program can not support Mac os, I know this maybe a good tool too, so any similar program recommend? My budget is under 50$, please

There are various ways to download YouTube videos. But when it comes to Linux, nothing beats youtube-dl. In this tutorial, I am going to show the steps for using youtube-dl for downloading videos from YouTube and other websites.

Of course you are always welcome to use the Google APIs Client Library for Python to wrestle with YouTube, which is usually pretty simple. (As an added bonus, YouTube has some nice runnable sample scripts to get you started.) With the client library, listing videos in a YouTube playlist is a breeze.

However, if you don't feel like writing code yourself (I usually don't feel like writing code myself until I use something often enough and existing solutions are suboptimal), youtube-dl recently added the functionality to list videos in a playlist with the --flat-playlist option.

According to one of the project collaborators, currently --flat-playlist is only helpful with the -j option for dumping JSON (so I suppose this feature is subject to change). For instance, --flat-playlist alone would emit something like this:

By the way, youtube-dl supports playlist bulk download natively. The reason I need a list of video ids or URIs, however, is that among other things, youtube-dl doesn't download highest resolution DASH video by default, so I have to rely on something like youtube-dl-dash (link) to download the best version.

To download a playlist from YouTube we can use youtube_dl . its a command line program to download videos from www.youtube.com and other sites (I had not tried other sites but YouTube download worked for me). It requires python 2.6 or 2.7 or 3.2+ . Also it is callable from any programming language , such as python . But I want to use it as a command prompt in this post .

Download audio and video separately : This command will download the audio from the given video/playlist, convert it to an MP3 and save it in the current directory. Please note that you should install either ffmpeg or avconv to convert the file to mp3 format. Similarly, to download audio files with best quality:

If you've got xsel installed you just have to select the youtube url in the browser address bar before running downloadpl in a terminal.
(The "$@" is just so you can throw in any extra youtube-dl options - I seldom do though.)

Generally I prefer to leave it up to youtube-dl to choose the format with the best quality sound, even if it means unnecessary download bandwidth. People paying by the byte will have different priorities I guess.

I've looked in the manual and haven't found a reference to '140'. Are you saying that 'youtube-dl -F url' should be run first in order to know what's available? If so, I think for a generic quick command -x might be better:

FORMAT SELECTION
By default youtube-dl tries to download the best available quality, i.e.
if you want the best quality you don't need to pass any special options,
youtube-dl will guess it for you by default.

Don't have an answer for that (It may be missing, but more meta request like 'bestaudio' may be also missing), as of quality I doubt that youtube, much less youtube-dl actually knows what's the best quality, they probably mean bitrate. < educated guess. edit: Best quality is probably opus, but it is contained in webm, so some ffmpeg post will be made to 'opus' it (again unless you target it directly '-f 251').

Run time is almost the same: clearly neither -x nor -f 140 are downloading the video data. The .opus file is very slightly smaller than the .m4a but that's not important I guess. ffmpeg is invoked to extract the audio from the webm file, but I'm assuming that it's simply unpacking it from the webm container, not doing any real processing. Very open to being contradicted on that though.

But my other point still remains, I think: to know that -f 140 is available for some particular download it's necessary to run 'youtube-dl -F' first. And sub-point: I haven't found anywhere where the format numbers are documented.

Really this is the difference between us I guess. I'm prepared to rely on the youtube-dl devs to know their stuff and just send -x meaning "do your best". For a quick-and-dirty rip of a free bit of audio from a public wiki that's all the time and effort I feel like putting in.

I was starting to wonder if I lived in a different universe from you two guys, because that's quite contrary to my experience. As you can see in the terminal o/p I posted above, for me "-x" takes almost exactly as long to run as "-f bestaudio" or "-f 140". The manual didn't shed any light, but inspiration came with the youtube-dl README on GitHub: -org/youtube-dl#format-selection

Since the end of April 2015 and version 2015.04.26, youtube-dl uses -f bestvideo+bestaudio/best as the default format selection (see #5447, #5456). If ffmpeg or avconv are installed this results in downloading bestvideo and bestaudio separately and muxing them together into a single file giving the best overall quality available. Otherwise it falls back to best and results in downloading the best available quality served as a single file. best is also needed for videos that don't come from YouTube because they don't provide the audio and video in two different files.

f5d0e4f075
Reply all
Reply to author
Forward
0 new messages