 What are we going to work on today? Well, today we're going to be downloading some music from YouTube, some songs I wrote, and we're going to be using YouTube DL. But actually, before anyone comments, I'm actually not using YouTube DL. You'll see that in the script. I'm just saying this now because someone's going to comment on it. I'm actually using YT-DLP, which is a fork. Some people consider it a better, and I think it's kept up to date more than YouTube DL, but I already had a bunch of scripts, including one like we're about to look at where I've used YouTube DL. I actually just have YouTube DL linked to YT-DLP. Just be aware that I'm not actually using YouTube DL, but it's going to work the same if you do. That's not the main focus of this video. What we're going to do is talk about naming our scripts, and depending on what we name our script, it's going to act differently. Hopefully, you'll understand what I'm saying by the end of this video, but an example of this you may have experienced if you ever worked with Busybox. Busybox is a single binary that has a whole bunch of your core tools, DD, CP, LS, all that sort of stuff built into one binary, but you can link it to LS or DD, so you don't have to write Busybox LS. You can just type LS and it will run Busybox and know that you want to run the LS command because you've linked it as LS. You'll see what I'm talking about here in a moment. Let's go ahead and look at our script here. I have a file in my directory called YT Music, and it's a script to download files from YouTube and convert them to audio format. What does the script do? First thing it does is look, do I have an argument, that first argument. If it exists, then create a variable called URL and make it whatever that first argument is. If I don't pass an argument, well then it's going to check my clipboard to see if I've copied a URL and put that into the URL. I don't actually ever check in here to make sure it's a valid URL because YouTubeDL will just let me know if it's not. I then echo out the URL just for output to the screen for testing, but then we're using our program here. We're going to extract the audio and we're going to audio format up here. I've coming out, but these are the audio formats that YouTubeDL or UT, yeah, you know what I'm saying, format offers. But right here is going to convert that URL to an MP3. So let's go ahead and here is a song I wrote. If you don't know, I write music. I have a channel on YouTube, which apparently has 57 subscribers, Linux Music Master. Anyway, I'm going to take that URL, I'm going to copy it. Now, I could pass it the URL like so and download it, but if I just run the script, run the script without a URL, it will check my clipboard as we just looked at in the script. So I'm going to do that, that goes out the URL, then it's going to download it, it's going to download it, and then I believe it uses FFMpeg. It's using FFMpeg to convert that to an MP3. So I can list out the files here and you can see that I now have an MP3 of that song. Let's go into that script. And again, we have these different formats up here. So let's say I wanted it to be a WAV file. I can just say WAV here and I can run the script again. It's going to look at my clipboard, download that file, convert it to a WAV file and I list out and I have an MP3 and a WAV file. So the question here is, how can we have one script that knows what format I want? Now, I could always pass an argument. I want this format and there's different ways to do that. You can do little switches, but if I do arguments, I'm already looking at the first argument as the URL. I could say, okay, is that a format? Is this that? But we can go simpler than that. So what I'm going to do is I'm going to go into our script here, my team music. And as we've talked about in the past, if you were to, let's say, echo out $0, that's your very first argument. It's the very first part of your command. So it's going to be the name of your command. So let me go ahead and do that. And then I'll exit out at that point, but I'll just say YouTube music. And it says that's the name of our script. And we'll give the full URL, our full path name, if I gave it the full path name. So what I can do in here is I can say base name, which will give us just the base name of our script. So what I want to do now is I'm going to look at that. And if I want to, I can name it different ways. But for me, for this particular instance, I'm going to have a YT MP3, a YT wave, a YT AAC. And it's going to look at that name and take that value. So what I'm going to do for my example is I'm going to say said, and then I'm going to run this. And I'm going to say, remove that YT. So now if I was to run this, and like so it's just saying music. But if I was to link to that file, so ln dash s, and this file, and then I can say MP3, I now have, if I list out all my files here, I have my music files, but I have our YT music, but then we also have YT MP3 pointing to YT music. If I was to run YT MP3, it's going to output MP3, right? So I hopefully you see where I'm going with this. So I go back into here. And then what I'm going to do is create a variable called format. And I'm going to set it equal to the output of that command. And then over here, I'm going to use the variable dollar sign format. Great. So now what I can do is I can link that to that. And then I can also say wave. And let me go ahead and just remove those files we downloaded earlier. So you can see I have one script but linked to different names. So I can say YT MP3. Let me make sure I still have this in my clipboard. YT MP3. I go like that. And what it's going to do is it's going to download and based on the name of my link, it's going to download an MP3, even though it's the same exact script. If I list it out, you can see I have an MP3 now. If I go YT wave, I can now run that. And again, it's going to run the same script, but based on the name of my link. And this will work if I rename the script as well, but we're linking to it multiple different ways. Now I just downloaded the wave format of that. Now one more thing you might want to do is go into that script and add into it a pipe symbol here and then run this same command, YouTube, extract audio, and then dollar sign URL. What's that going to do? Well, let's say I was to make a mistake. So you can download AUG files, but it doesn't say AUG up here. Or you would do this VORBUS, I think? Or is it? Yeah, I think VORBUS is the AUG format. Or if I was to run the original script, which is music, which isn't a format. So what's going to do now, it's, oh, sorry, I have something else in my clipboard. Copy that again. So we'll run the script with its original name. It's going to try to download that as a format of music. That doesn't exist. So then it will default to whatever it considers the best format. In this case, it's OPUS. So I can list that out. I have OPUS. So it will look at the file name, cut it down. If that is a format that works, it will download. If not, it will let you know that's not, and then it will download the best format. So yeah, I will put this up on Payspin and link to it in the description of this video. But I hope you found this useful. So again, I can do all these different formats. I can have YTACC, YTFLAC, YTMP3, YTM4A, YTOPUS, VORBUS, and WAVE. And then, depending on what I want to download, I can just run that same script. I can just link them all. I can put all the main script and all the links to them in my, for example, USR local bin folder. And then anytime I highlight a URL, I can just run that command. If I just want to download the best format, I'll just run YTMusic, but I can run the other commands, and it will hopefully download those formats for me properly. So that's it. I hope you found this useful. I hope you visit FilmsByChris.com. That's Chris at the K. There's a link in the description, also a link to the script. And remember, I do have a Patreon page linked to that in the description. And, you know, I would love your support. I appreciate the supporters I have on Patreon. I talk to a few of them regularly, and I've helped them, and they've been very helpful with me working on stuff. And I'm just thankful to have them. I would love to have more supporters. And if you can't support that way, you know, think about liking, sharing, subscribing, commenting. If you are a Patreon member, you usually get most of my videos a week or more in advance. So, there you go. That's what you get. And you also can contact me. And I actually make time. I have a lot of questions I get asked on Facebook and stuff, and in comments, I don't have time to answer most of them. But if you're a supporter on Patreon, I definitely have time to talk to you. So, I appreciate that. And I hope that you have a great day.