This allows the user to, as the name kinda suggests, click on a javascript bookmarklet while on a YouTube video page to download the video in the background using yt-dlp and open it afterwards in VLC. VLC will be paused and minimized so you can click on the tray icon to watch the video whenever you want. For your convenience, the downloaded video file is automagically deleted once you close VLC.
Sadly, this only works on Windows. Look at How it works for an explanation.
- Clone this repository or download the individual files and put them wherever you want them to reside.
- Compile protocol handler.c.
- Edit the last line of add protocol to registry.reg to reflect the location of the resultant
protocol handler.exe
.
Pay attention to escaping quotes and backslashes properly! - Merge add protocol to registry.reg with the registry.
- In Firefox, import the bookmark from the provided HTML file and put it wherever you want.
As long as you don't modify the JS code inside of the bookmarklet, even the icon will stay!
When you click on the bookmarklet, a small snippet of javascript code is executed. This will grab the video ID from the current page (and check whether you even are on a valid video page)
and attempt to open a special url: yt-dlp://
followed by the video ID.
This is a special protocol defined only on your computer that will call protocol handler.exe
. All the protocol magic is built into Windows and can be set up using the registry.
Once protocol handler.exe
is run, a Command Prompt window will pop up. You can minimize it or use it to moniter the progress of the download.
This will call yt-dlp with a set of predefined parameters:
- The video's resolution will be 1080p or the best available resolution below that.
- The final file will be in a .mp4 container.
- All temporary files will be stored at
%USERPROFILE%\Videos\yt-dlp_tmp\
.
Afterwards, VLC will be opened, but remain paused and minimized to the tray icon.
That's pretty much it!
Thank you to Endermanch for his video on Windows protocols, which taught me how they work and how to create one yourself.
Thank you to Tsoding for his nob.h, from which I stole learned how to run new processes on Windows.