Integrating Youtube downloader into Vivaldi (tutorial)
-
YT-dlp is command line utility that downloads video from Youtube. It is a fork of the Youtube-dl. Although it name is youtube downloader, it can be used for downloading videos on a huge number of other sites.
The purpose of this tutorial is to achieve the simplest possible way for downloading current video or playlist by integrating the YT-dlp in the Vivaldi browser.
Requirements: YT-dlp, ffmpeg (required by YT-dlp for format conversion), Vivaldi on Windows, admin rights.
Let’s begin.
Download the YT-dlp.exe and FFMPG.exe and save both in a same folder.
Unfortunately, Vivaldi doesn’t yet support startup of an external programs (support the feature request). That's why it is necessary to use URL protocol. The first step is to define the protocol. It is done in the Windows registry, which requires the administrative privileges.On HKEY_CLASSES_ROOT select New>Key by clicking the right button. Any name can be used, I’ll use ytdlp for the example. If you use another name, replace it wherever ytdlp is used. Then select New>string value and enter URL Protocol as name.
Create three new hierarchical keys that are appropriately named shell, open, and command. In the command key for value data enter:"d:\Programs\youtube-dl\DownloadYTVideo.bat" "%1"
Adjust the path to the folder where you have saved the program and where the batch created in the next step will be saved.
In the end, the registry should look like in the screenshot.
The second step is to create the batch script. This intermediate step is required to parse the parameter that is sent to the YT-dlp. Copy content of the script in the text editor and save it as DownloadYTVideo.bat in the same folder where YT-dlp is.
@echo off SETLOCAL ENABLEDELAYEDEXPANSION set vidurl=%1 set vidurl=%vidurl:ytdlp:=% set vidurl=%vidurl:"=% set vidurl=!vidurl:%%20= ! echo %vidurl% d:\Programs\youtube-dl\yt-dlp.exe %vidurl%
The last step is to create a bookmarklet in the browser, which actually calls the script with the current address as a parameter.
This can be done in two ways.The first way is to create a new bookmark. The key part is the address:
javascript:location.href='ytdlp:'+document.location;void(0);
Be careful, the browser may cut the section up to the semicolon. If that is case, type it.
Enter name for the bookmark, description and nickname are optional.You can call the bookmark from bookmark menu, the bookmark bar or from the panel.
The second way is by creating a new chain command. Select ‘Open link in the current tab’ as command and as parameter enter the same javascript code from above. The command is immediately available from the command browser. It can be added in the main menu or the right click pop-up menu. If you wish you can add a keyboard shortcut or mouse gesture. All combinations are possible.
If required, you can define multiple commands or bookmarklets with different parameters. For example, to download in a certain format or to just download the audio.
Hope find this useful.
-
@solidsnake Great guide and a useful hack!
I don't use the tool a lot, when I find the need I just copy the URL and open a cmd window but this is definitely useful
-
What an awesome idea.
Thanks!
-
@solidsnake Cool. Almost there. Before I got an "max recursion level reached" [on loop] (fixed the batch name) and now a
file access error
(because cmd is not executed as admin, perhaps?). -
@hadden89 said in Integrating Youtube downloader into Vivaldi (tutorial):
@solidsnake Cool. Almost there. Before I got an "max recursion level reached" [on loop] (fixed the batch name) and now a
file access error
(because cmd is not executed as admin, perhaps?).At what point you get the error?
CMD is executed as normal user, not administrator. The administrator user is only needed to edit the registry during the setup.Maybe some policy disables using CMD?
-
@solidsnake Don't think so. Everything is admin, here. The only GPOs is the one to lock automatic updates
At what point you get the error?
The end, after the bookmarklet+script launch. It takes the video url but it throws the error. If I try the same with a regular cmd console using
yt-dlp <url_of_the_video>
everything works (even as user, which also is admin after all).yt-dlp console when launched within vivaldi throw this:
ERROR: unable to open for writing: [Errno 13] Permission denied: <file_name>
-
@hadden89 I've never encountered that error.
Quick search on yt-dlp says it is permissions issue or unsupported chars in filename.
Try changing the dl location in yt-dlp, to see if helps? -
@solidsnake Could be.
unsupported chars in filename
But the same files fetched manually, so I'd exclude that.
permissions issue [...] Try changing the dl location
Likely. I'll try to move the whole folder to a
D:\
subfolder and see if solve the un-readbility issue -
Not totally related, but I also found a Nice GUI for yt-dl