0

I'm currently writing a script in which I need to download the latest version of yt-dlp.exe from Github. Since the script will need to work on multiple machines, I opted to use curl as the downloader. I found this script on some other site which I adapted for the program I need.

for /f "tokens=1,* delims=:" %%A in ('curl -ks https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest ^| find "browser_download_url"') do (curl -kOL %%B)

Only problem is that it fetches the entire latest release set when I need just one file! Is there a better way to do this without using powershell?

Thanks!

2
  • Please define better how to distinguish this one file from the others.
    – harrymc
    Commented Jul 25, 2023 at 19:14
  • That's a bit the problem right now as after a sleepless night, my brain can't seem to figure this one out. I'm thinking of using a loop to do the work but I feel there is probably a better way.
    – Flaver-D
    Commented Jul 25, 2023 at 19:40

2 Answers 2

1

While there might be better ways to get the latest yt-dlp version...

To answer your question, you simply need to modify the script to look for yt-dlp.exe. Currently, it fetches the GitHub API page of the latest releases and looks for all things that have a browser_download_url (which are the lines with the download links), you need to change that to look for the yt-dlp.exe line.

Try:
for /f "tokens=1,* delims=:" %%A in ('curl -ks https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest ^| find "yt-dlp.exe"') do (curl -kOL %%B)


The official documented way of Linking to releases is by putting releases/latest/download/ in the assest link where you usually have releases/download/{release version number}/.

So in your case, you can very simply download the file from:
https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe

3
  • Why didn't I think of doing that? Thanks for putting me on the right track!
    – Flaver-D
    Commented Jul 25, 2023 at 20:14
  • See my edited edition, certainly a better way to do it Commented Jul 25, 2023 at 20:16
  • Now that is simple 😊. I'm updating my script as soon as I get to it! Thanks!
    – Flaver-D
    Commented Jul 26, 2023 at 14:53
0

To simplify, on Windows 10 you can install the latest version by using the built-in winget like this :

winget install yt-dlp

To update, run:

winget upgrade yt-dlp

Source : yt-dlp Installation.

2
  • This would work but it does pose the problem that you can't choose where the program gets installed.
    – Flaver-D
    Commented Jul 25, 2023 at 20:21
  • Winget has the -l parameter. See link. Note the limitation.
    – harrymc
    Commented Jul 25, 2023 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .