You are not logged in.

#1 2012-12-27 06:17:35

armb78
Member
Registered: 2012-12-26
Posts: 29

How I use aria2 to download torrent files

I was reading topics' titles, and then I saw this one:
https://bbs.archlinux.org/viewtopic.php?id=154476
At first, he wanted to use aria2, but then he switched to rtorrent. rtorrent is great, but It's not good for scripting, so I don't use it. aria2 is the best way to download torrent files, within command line. But how?
I use this script, because sometimes aria2 stops downloading, but doesn't exit! It's not a big deal when you're near the computer, but when you go somewhere else, you can't check if it's downloading. So I wrote this little script:

#! /bin/bash

if [ ! -x /usr/bin/aria2c ]; then
    echo "aria2c is not installed"
    exit 1
fi

if [ ! -d ~/.torrentdl ]; then
    mkdir ~/.torrentdl
fi

while :; do
    for i in $@; do
        MAGNET=false
	if [[ "$i" = magnet* ]]; then
	    MAGNET=true
	elif [ ! -f "$i" ]; then
	    echo "The file ('$i') is not given or does not exist"
	    exit 1
	fi
	if ! aria2c --hash-check-only=true "$i" &> /dev/null; then
	    aria2c "$i"
	    sleep 30m && kill -9 `pidof aria2c`
	else
	    echo "Torrent is downloaded!"
	fi
    done
done

Simply, it starts downloading and restarts it every 30 minutes.

There are some arguments that will help you with aria2:

-S, --show-files[=true|false]:
Print file listing of ".torrent", ".meta4" and ".metalink" file and exit.  In case of ".torrent" file, additional information (infohash, piece length, etc) is also printed.

--hash-check-only[=true|false]:
If true is given, after hash check using --check-integrity option, abort download whether or not download is complete.

Offline

#2 2012-12-27 06:21:50

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: How I use aria2 to download torrent files

Maybe this belongs in the wiki, specifically the "Useful Tips and Tricks" section.  It is not vital to usage of aria2, but I am sure there are others that might find this useful, and the wiki seems like a much more logical place to go searching for something like this.

Offline

#3 2012-12-27 07:00:16

armb78
Member
Registered: 2012-12-26
Posts: 29

Re: How I use aria2 to download torrent files

Offline

#4 2012-12-27 07:16:03

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,840
Website

Re: How I use aria2 to download torrent files

Thread belongs in Community Contributions: moving...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB