User Tools

Site Tools


dl-aria

Download using the aria2 download manager

Description

This is a simple script which downloads files using the aria2 download manager by sending URIs to an aria2 daemon. Supported protocols are HTTP(S), FTP, BitTorrent and Metalink. Also uses cookies and can download a file from HTTP/FTP and BitTorrent at the same time. Needs at least aria2 version 1.4.0 (with the XML-RPC interface) and the commandline utility aria2rpc. You can then use tools like aria2mon to check the status of your downloads in the command line, or write your own utilities using the XML-RPC interface. See also http://aria2.sourceforge.net/ for more information.

Source

#!/bin/sh

# Options
useragent="Firefox"
target="$HOME/Downloads"
cookiejar="$HOME/.local/share/uzbl/cookies.txt"

# XML-RPC settings (I recommend you change this)
rpcport="6800"
rpcuser="uzbl"
rpcpasswd="uzbl"
rpcserver="localhost"

# Try to add URI to running instance of aria
aria2rpc --server $rpcserver --port $rpcport --user $rpcuser --passwd $rpcpasswd addUri $8

# If it failed, aria probably isn't running yet
if [ $? -gt 0 ]; then
    # Start new instance of aria
    aria2c -D \
        -d $target \
        -U $useragent \
        --load-cookies=$cookiejar \
        --enable-xml-rpc \
        --xml-rpc-listen-port=$rpcport \
        --xml-rpc-user=$rpcuser \
        --xml-rpc-passwd=$rpcpasswd >/dev/null 2>&1

    # Now try again
    aria2rpc --server $rpcserver --port $rpcport --user $rpcuser --passwd $rpcpasswd addUri $8

    # If it failed once more, fall back to wget
    if [ $? -gt 0 ]; then
        ( cd $target && wget --load-cookies $cookiejar --user-agent $useragent $8 )
    fi
fi
dl-aria.txt · Last modified: 2016/08/31 14:10 (external edit)