Episode: 2710 Title: HPR2710: Youtube downloader for channels Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2710/hpr2710.mp3 Transcribed: 2025-10-19 07:57:21 --- This is HBR episode 2,710 entitled YouTube Downloader for channels. It is hosted by Ken Fallon and is about 14 minutes long and carries an exquisite flag. The summary is a follow up to HBR 2,675 how you can download an entire YouTube channel for local playout. This episode of HBR is brought to you by an honesthost.com. With 15% discount on all shared hosting with the offer code HBR15, that's HBR15. Better web hosting that's honest and fair at An Honesthost.com. Hi everybody, my name is Ken Fallon and you're listening to another episode of Hacker Public Radio. Today, I'm doing one in response, doing a show in response to episode 2675, which you all know is YouTube Playlist, how to solve a problem with following YouTube channels by Ahuka, which is posted today as I'm recording, which is the second of November. And this was an issue that Ahuka wanted to watch sequential shows. So if somebody's done a series, you wanted to watch them in order and start with the oldest one first, obviously, and then walk away through. This seems entirely logical to me. And so much so that I have wanted to do something very, very similar some time ago, and as you know, I have a one and a half hour commute in and out of work about an hour of that is in the train, when the rest is in the bus. So in the bus, I tend to listen to podcasts and on the trains, I now I'm catching up on electronics and other hacker-y-type stuff, YouTube channels. And that's a, that's a, that's a HPR episode for another time. So what I wanted to be able to do was do exactly what Ahuka has done and start at the first episode and work my way through a channel, ensuring that I've watched each and every episode in the order that they were released. And yes, that's very difficult to do on the, on the website, but it's also, I had the additional desire and that was I wanted to download these episodes locally so I could play them locally. And once you start talking about downloading locally, then I could put them onto my phone, have them on the NAS, and then watch them on the main TV or on my laptop or wherever up to be out in the back room. And also put them onto my phone and then watch them as I'm on the train going into work. So the answer to this is a bash script, surprise, surprise, surprise. And the bash script is called YouTube-channel-watcher. And it basically, I claim no power for myself. This all comes from the tool YouTube DL link in the show notes, which is an absolute excellent tool for doing everything with not only YouTube channels, but various different channels out there. If you just type YouTube-DL on space and then the video ID of a YouTube video, it'll just download it for you. But there's so, so, so much more that it can do. So if you, for example, have a YouTube video and you want to download the entire channel, if you go to the website of said YouTube person. So I'm just going to pick some of your random and let's go to YouTube and then you click on there the video that you are watching and then you click on the username and that's just copy that URL. So YouTube.com, for size user, for size, it's either a complicated ID or it's an ID of of, you know, so bigclive.com or something like that. And you will have that. Then you put that into a file called subscriptions.text, subscriptions.text. And you make a list of your YouTube channels that you are subscribed to and you add them to this file. So bigclive.com, Julian Eglett, I like to make stuff, whatever, whatever sort of channels that you want to listen to. The idea of the script is basically to do something similar to what Bash Potter does. And that is to read the text file, find out the latest file that was downloaded and then download anything since then. And how would you do that is a good question. So posted in the show notes will be a YouTube channel watcher script, which just before I even go any further, I don't use this full time now. I use this tool to, when I find a new channel, I use this to download all the channels, all the videos up until the point, which I really don't need to when I explain the script to you, but it's convenient for me to do that. So I've actually switched to using something else that Dave Morris did a show about. And I'll talk to you that about that in the next episode of this kind of mini series. But first to do what it is that a hooker wanted to do and that was download an entire channel and keep the channel up to date. So this basically looks for a subscription file. The first few parts is it's got a save path, it's got a subscription text, it's got younger than. So it will download files younger than and a particular date in ISO 8601 format a year month day without the delimiters and it sets the run date. So last time it was run and it gives you a path to YouTube DL, which allows you to specify the YouTube DL version that comes with your application or your distribution. So DNF install YouTube-DL or aptget apt.get apt-get space install space YouTube-DL. Now the issue with that is that like I think either directly or indirectly YouTube tries to break this script but it seems to break probably once or twice a year and the solution to that is I just downloaded it directly from GitHub and I have that in my source code directory and then when it breaks I use the one in GitHub using YouTube-DL space dash capital U for update and that will upgrade itself and then you have the latest version and that usually fixes is if it breaks then I if it's still broken I usually wait a day or two, run that again and then everything's on the Dori. So that's a that's a good thing. So this entire thing this entire series based on YouTube DL it is a fantastic fantastic tool and well done them. So the first thing it does this script does is it checks to see if there's a subscriptions if I can find my subscription file and if there is a last run it looks for a tag called last run which I just put out the top of the file just tells you when the thing was run it's just for my own my own information. So the idea here is that I then cache the subscriptions file removing all the comments into a read loop and in the read loop I look for a a delimited with a tab to see what the last run date was. So as this is the first time there's going to be no last run date but in this in my particular example here the last time this thing was run was two days ago. So the date 2018 10 30 is three days ago actually is tab to limited so I've got the URL of the user big cloud.com tab 2018 10 30. Why that's important is it will look for videos that have been posted after that date. So essentially YouTube DL supports a function or a option called it will look at when the video was posted and if it was posted you can specify show me all videos before this time after this time or between using the before and after date you can get the between function. So what this one does is the very first time I want to run it I want to run all the videos since YouTube was started and download them but say for example you only wanted all the videos in 2018 you were put 2018 0101 as they younger than data. So that basically decides what the date is going to be. If the date is not found at the end of the URL line then it'll use the default one and if it is it'll use that instead. So it'll then go on to find out what the channel is using the channel info which is the URL. And it'll get the first part of that and basically say it'll start downloading it. And the command is YouTube DL and then dash dash date after and the date that we picked from before. Ignore errors meaning that if it comes across a problem a video is missing or something that just skip. No M in time which is important because the post date may not necessarily be the date that they have on their servers so quite often when I wrote this script first I the video files were completely out of date because the no M time was there. So what this does is it just writes they writes the date based on file name for now. It does the next option is dash dash dash file names so that gives you nice ASCII type file names if there are extended characters that extend outside of that they get normalized down tasky. Next option is dash dash format which I have as mp4 because I found that to be the best generic option. You can specify other options there like best or whatever but I don't bother doing that. So now this is the key part here which is the option to save your file and just as with k3b burn burn burn software or media players or whatever you have various different options in which to save using various different attributes. So if you specify the dash oh which tells you the output location and then I have a save path to where I want to save it. So I have slash percent and in brackets the word uploader and then after the close the brackets is an s so that's the term that tells youtube dl that is use the uploader name as the save directory and that is going to be safe url I'm not sure about that yes I think it's going to be a safe url so it'll be big live underscore dot com or something or I like to make stuff will be I underscore like underscore to make stuff with all underscores then forward slash and this is the key to getting them in sorted order. I use the parameter upload date which is again in a percent open bracket upload date close bracket s dash percent title s and then I use they use a diamond unicode character to and then the ID of the video dot and the extension and then the final thing is the channel name which is they which is coming from the text file. So I don't think I'm really explaining this very well but I suppose anybody listening to my shows will be well used to that. So basically ignores don't write the m time convert the file names save it as mp3 save it into a directory using the uploader's name so big live dot com and in that directory save the files with the upload date so that'll be an ISO it's a one date year month day dash the title that they've given us which will all be nice a fight and then the diamond sign all ground less than greater than will give you the diamond key or you can use that in the limits you want doesn't really matter but I use that one because because of youtube's sixty four bit type encoding so and then you get the extension and that's pretty much it and then after that's done is goes through the subscriptions file. And it looks for the channel name and it adds the last run date which is today so the run date of today at the end of the subscription file URL using the segment which we learned from Dave in his said series. I actually did copy and paste this from Dave's said serious surprise so that then updates the URL in the subscription file so that like the end the next time it runs it'll look at that date and goes hey oh I already have this video I don't need to download. So that will loop through all the script subscriptions and then at the end it'll go it'll update the first file for the last run command at the comment at the very top of the file. So fairly simple examples in the show notes it'll be very obvious to you what's going on when you look at that there. One thing about this is it's quite handy insofar as it will only download newer episodes but the problem with it is it will go to somebody like the EEV blog and there are thousands of episodes. He's been going for all several years now and releasing two episodes one episode a week so it's two or three hundred episodes. So every single time YouTube DL needs to go to each URL find out what it is check and see if it's newer and then skip and go to the next one do the same thing do the same thing. So this is why it's very slow and very slow to run ideal for if you want to download an entire channel in one go but after that it's probably best to use something else and that will be the subject of my next episode. So tune in tomorrow for another exciting episode of Hacker Public Radio. You've been listening to Hacker Public Radio at Hacker Public Radio dot org. We are a community podcast network that releases shows every weekday Monday through Friday. Today's show like all our shows was contributed by an HBR listener like yourself. If you ever thought of recording a podcast then click on our contributing to find out how easy it really is. Hacker Public Radio was founded by the digital dot org and the infonomicom computer club and is part of the binary revolution at binwreff.com. If you have comments on today's show please email the host directly leave a comment on the website or record a follow up episode yourself unless otherwise stated today's show is released on the creative comments, attribution, share a live 3.0 license.