How to create browser integration of youtube-dl?

52 risposte [Ultimo contenuto]
pragmatist

I am a member!

Offline
Iscritto: 03/03/2016

Yes, it does not take long. As I mentioned above, in my case, I just paste the URL into a terminal after the characters tt SPACE
While it sounds like it would take long because of the number of steps, I'd be shocked if it ever takes more than 2 seconds; More often than not closer to 1 second:
1.) double-click in URL bar which highlights the URL
2.) scroll mouse over workspace switcher to switch to a workspace that already contains only a maximized terminal. This way focus is always given to the terminal.
3.) type tt SPACE
4.) press the middle mouse button
5.) hit ENTER

It takes longer to write that, and longer to read that, than it takes to execute it. Maximum of two seconds.

Alternatively, if you don't want to leave a terminal open, or you don't use workspaces, or you just like using the keyboard you can:
1.) ALT-d (or CTRL-l) to select URL
2.) CTRL-c to copy URL
3.) CTRL-alt-t to run terminal (or whatever shortcut you use to run a terminal or run a command)
4.) tt SPACE
5.) CTRL-SHIFT-v to paste URL
6.) ENTER

Depending on how fast you type that can be slower or even faster than the mouse method. With a little practice it probably would not take most people more than 2 seconds to do that.

More often than not I just use the video everywhere plugin. Since I've posted to this thread, however, I've had several occasions where the video everywhere plugin didn't work but the above method did.

Sometimes simplest is best. When you take all the hours it is taking to write this script, and divide it up, it will take a while to 'pay that back' to where the extra time saved is really a benefit. For example, if hack has spent four hours on this already then that equals 4 * 3600 = 14,400 seconds. Even if he shaves a second off the above method, it will take him 14,400 downloads just to break even! Obviously, if you are a very experienced bash script writer it would probably only take a few minutes to write this script and could therefore be useful.

For educational purposes, however, this exercise can certainly be useful; I know hack is learning a lot from this. From an efficiency standpoint, however, it makes sense to work on scripts that are directly worth the time invested. Then, as you become more experienced, a job like this one will go much faster and be worth it as well. This is an especially good practice for learning bash scripts which are often all about saving time anyway.

hack and hack
Offline
Iscritto: 04/02/2015

Yeah, well for those who'd rather push 2 keys instead of doing it in several steps every single time,
here's a version of 2 scripts that work for me (though the one for streaming in particular could be better):
For streaming :

xclip -selection clipboard blank
xclip -i /dev/null # these 2 erase the clipboards. It seems there are 2 clipboards. I don't understand much of it yet
xdotool key ctrl+l # xdotools needs to be installed. This selects the url.
xclip -selection clipboard blank
xclip -i /dev/null
xdotool key ctrl+l
# I've written these 3 commands twice because I noticed I had to launch the script twice to copy a new url. Barbaric coding, but it works for me. Maybe you won't need as much if you're on a full install. EDIT: after a quick test, I just need the xdotool command twice, nothing else.
vlc $(youtube-dl --prefer-free-formats -g $(xclip -o))

For downloading :

cd ~/
xdotool key ctrl+l # xdotools needs to be installed. This selects the url.
var=$(xclip -o) # You also need xclip installed. this puts the copied url in a variable before youtube-dl uses it. Else, sometimes it failed without doing that in my experience.
youtube-dl --prefer-free-formats $var

Since it uses youtube-dl, it covers more ground than say,
Unplug which is still a good, simple option.