You are not logged in.

#1 2018-02-03 22:13:51

devnull
Member
Registered: 2017-06-29
Posts: 69

[SOLVED] Troubles with a simple youtube-dl keybind

Hello everyone,

So, to speed up the downloading of videos from youtube I wrote a simple line to have youtube-dl to download the audio from the link I just copied, like this

youtube-dl -x --audio-format vorbis -o 'home/user/Music/YoutubeDL/%(title)s.%(ext)s' $(clipit -c) && notify-send 'Audio downloaded'

Now, I'd like to assign the code to a keybind, so I can quickly download videos. I tried in two ways:

assigning an alias in .bash_aliases like youtubeclip and adding this line to ~/.config/openbox/rc.xml

<keybind key="W-A-y">
   <command>youtubeclip</command>
</keybind>

Running youtubeclip from terminal works perfectly, but using Windows-Alt-y doesn't. Ok, so I tried using the code plainly in the file, like this:

<keybind key="W-A-y">
<command>youtube-dl -x --audio-format vorbis -o "home/tombom/Music/YoutubeDL/%(title)s.%(ext)s" $(clipit -c) ; notify-send "Audio downloaded"</command>
</keybind>

Nothing happens neither.

Before you ask: yes, I did openbox --restart and yes, I had a youtube valid link in the clipboard.

Why is OB behaving like this? I thought we were in love...

Last edited by devnull (2018-02-04 10:42:04)

Offline

#2 2018-02-03 22:28:18

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,068
Website

Re: [SOLVED] Troubles with a simple youtube-dl keybind

devnull wrote:

assigning an alias in .bash_aliases like youtubeclip and adding this line to ~/.config/openbox/rc.xml

I don't think shell commands executed by rc.xml use bash (and even if they do I don't think they'll read ~/.bash_aliases) — try calling a script instead.

devnull wrote:

I tried using the code plainly in the file

The rc.xml file requires special escape codes for certain characters and I'm guessing you didn't use those?

Offline

#3 2018-02-04 10:41:43

devnull
Member
Registered: 2017-06-29
Posts: 69

Re: [SOLVED] Troubles with a simple youtube-dl keybind

Hi, thanks for your reply!

So, I did as you say and created a script and call it.
Then I just add the <action name="Execute"> to the whole call on rc.xml, and works, great!

Just as a reference for others, my call on rc.xml looks like this

<keybind key="W-A-y">
  <action name="Execute">  
     <command>~/path/to/youtubeclip.sh</command>
  </action>
</keybind>

Offline

#4 2018-02-05 09:17:14

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,741

Re: [SOLVED] Troubles with a simple youtube-dl keybind

@devnull, Nice, will come handy next time I decide I need 'play this youtube url in mpv'.

done: https://raw.githubusercontent.com/bront … in/mpvtube

Last edited by brontosaurusrex (2018-02-05 17:59:12)

Online

#5 2018-02-05 15:36:20

qcgxr
Member
Registered: 2016-08-31
Posts: 29

Re: [SOLVED] Troubles with a simple youtube-dl keybind

Oh, I like the use of notify-send.

Also, though I imagine you are aware, perhaps others are not. ClipIt's custom actions can be used in order to select from several actions, e.g., a script to stream audio, stream video, download, or share. I find it indispensable. Then copy a link to the clipboard, C-A-a, and select your custom action. Hopefully someday I can figure out how to bypass ClipIt and pipe URLS into Rofi in order to select an action with less mousing...

Offline

#6 2018-02-06 12:35:34

devnull
Member
Registered: 2017-06-29
Posts: 69

Re: [SOLVED] Troubles with a simple youtube-dl keybind

qcgxr, thanks, I didn't know clipit could do that!

To pass the action to rofi shouldn't take much, just create an alias with a command that uses clipit data, and it should be readily available on rofi (I use dmenu_extended but should be the same thing)

Nice job, brontosaurusrex, glad I could be of some help.

Offline

#7 2018-02-06 13:27:25

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,741

Re: [SOLVED] Troubles with a simple youtube-dl keybind

@devnull, yeah well, sometimes one has to create something useless ..., after some tinkering, much better workflow (and no scripts needed would be):

a. Run mpv like

mpv --force-window --idle --autofit-larger=50% --geometry 49%+0+0

b. drag & drop from browser. Or shift drag & drop to add.

Online

#8 2018-02-07 13:22:31

qcgxr
Member
Registered: 2016-08-31
Posts: 29

Re: [SOLVED] Troubles with a simple youtube-dl keybind

To pass the action to rofi shouldn't take much, just create an alias with a command that uses clipit data, and it should be readily available on rofi (I use dmenu_extended but should be the same thing)

@devnull, I hadn't thought of that. I'll have to do some digging as I don't see a way to expose clipit's custom actions to a script. As of now, I've been slowly trying to build a (clumsy) equivalent.

Offline

#9 2018-02-08 13:48:35

devnull
Member
Registered: 2017-06-29
Posts: 69

Re: [SOLVED] Troubles with a simple youtube-dl keybind

You can just use clipit as an input for your script.

For example, if you want to create a file using what's on clipit  you can just do an alias like

FileFromClipit="echo $(clipit -c) >> ~/fileName.txt"

Then firing up rofi and selecting FileFromClipit action it will create the file.

Of course this is a very simple script, you can do way more complex stuff and just call the script from the alias.

If that's not the usecase you thought of let me know, maybe I didn't get it

Hope this helps smile

Last edited by devnull (2018-02-08 13:49:52)

Offline

Board footer

Powered by FluxBB