Jump to content

Request: Aria2 workflow

Recommended Posts

Hi guys, 

Well, I already posted something about how to launch aria2 (http://aria2.sourceforge.net) with Alfred. 

What would be nice, if anybody can do that, would be to highlight or copy a link to the clipboard, from any place (Safari or otherwise) and have aria2 download it thanks to a hotkey for instance.

I've been tinkering a little with workflows, but my knowledge is so limited I'm really stuck with this. So if anyone was kind enough to do it for me, I'd be more than thankful!

Cheers to all

Edited by bhanquier
Link to comment

That’s probably not something you’d be able to do with Alfred, at least not easily. To work like you want, Alfred would need to be talking to Safari (through Applescript) back and forth, and that’s really not something it’s designed to do. You’d have more success in breaking this down, i.e. having a Safari extension that could highlight and copy links to the clipboard, and then having an Alfred workflow to act on that.


Another way would be to find a browser extension that could do everything from start to finish.

Link to comment

Muito obrigado Vitor. 

Wow… that's certainly not something I could do!

What about a script like, copy the link in the clipboard, call an action in Alfred and paste the link to download? I've tried to do that and couldn't get anything working… Like I said I'm really not proficient in command-line and scripts and stuff, even though I try before I call for help.

Link to comment

A good tip is to try and get your script working (via the terminal), and only then try to port it to Alfred. Changing a script to make it work in Alfred is relatively simple, and the terminal is definitely a better place for you to do your tests, as you get useful feedback (like error messages) that’ll help you understand why something isn’t working. It’ll also make it easier to request help with specific problems on websites like StackOverflow.


It’s fairly simple to get your clipboard contents via the terminal, in OSX, you only need the command pbpaste (conversely, pbcopy will put contents in your clipboard). So let’s say you have a command like

curl "http://example.com"

that’ll use the command curl on http://example.com. If you want curl to act on something you have on your clipboard, you’d do

curl "$(pbpaste)"

the “$()” part tells bash “get whatever is between the parentheses and run it as a normal command, outputting the result”.

Edited by Vítor
Link to comment

It actually works, I'm thrilled! Still a little of tinkering (took me ages to get it to download in the proper folder, for some reason I can't get the config file to be read… could it be a problem with the "--" before the prefix?), but it's already a very good start. 

Thanks so much Vitor.

Link to comment

You’re welcome. It’s a great feeling when you first start to get your scripts to work.


Regarding the configuration file, I’d say it’s unlikely that is the reason, but I’d need to take a look at your code to try and see where the problem lies.

Link to comment

It's also very nice of you to spend the time to take me by the hand.

I've tried a couple of possible configurations. By default aria2 is supposed to look for the config file in $HOME/.aria/aria2.conf (but it doesn't), so there's the original there, and I made symlinks to it in various places to see if that would work, and no dice. 

Just so you know, my HOME folder is an entire partition, maybe it makes a difference - I'm saying this because I know it's given problems with bitcasa for instance, even though it's an entire different type of software, you never know. 

So the last code I tried was as such: 

./aria2c --conf-path=/Volume/bhanquier/Library/Preferences/aria2.conf -x15 "$(pbpaste)"

and I've also tried putting a symlink in the workflow folder, where the aria2c binary is by the way: 

./aria2c --conf-path=./aria2.conf -x15 "$(pbpaste)"

To get the download in the proper place I had to add an argument in the script, other wise it would download in the workflow folder: 

./aria2c --dir=/Volumes/bhanquier/Downloads -x15 "$(pbpaste)" 

One fortunate unexpected thing is, I get a notification when the download is finished, and I didn't do a thing about it expect link a notification sheet!

Link to comment

Got it! There were a couple of lines at the beginning of my config file that are dedicated to setting up xml-rpc connections in order to control aria2 via web browser; I guess they were interfering with any other means of communication. I removed them, and now it's working like a charm!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...