Quick torrent downloading from commandline

Whenever I actually sit down to write a post here, the first thing I can come up with to write is how long it's been since I've posted last, so without further adue:

Wow it's been a while!
This isn't going to be a full post, just a quick tip; I have a lot of these "tips" I've been meaning to write, so I'm starting here.
On a day-to-day basis, I wget a lot of files. [For non-unix gurus, wget is a commandline http/s ftp/s client.] It's now second nature for me to wget whatever tarball or file I need to get on a linux machine, but it's not so easy to do with torrents. This has annoyed me for a while now; it seems every time I actually need to get a torrent on a linux machine I have to go install something like transmission, then configure it, then test it because I'll invariably get that one weird bug that no-one knows about. While this isn't really a big deal in the long run, it's inconvenient to go through this process for just one torrent. I needed something that was as quick as wget or curl. Something that I could run in a tmux window and check later. There are, of course, ways to do this with transmission, mainly transmission-cli; I'm sure there are similar solutions for other linux torrent clients. This assumes, of course, that you already have transmission installed, configured and running, which made it a non-solution for me. Nice and quick if you've got a client you usually use and that is always running. Not so nice if you want wget-like functionality (run once, maybe seed to ratio 1.0 and then go away, as well as writing in current directory).

My solution

I tossed the idea of creating something to do this around for a while, there are after all libraries like libtorrent-rasterbar and it's asociated python bindings. In the end, I did the smart thing and actually looked for existing solutions. One of the answers on this stackoverflow question mentions lftp.
At first, I was skeptical. With a name like lftp... Well... Yeah. But after sudo apt-get install lftp and lftp -c torrent "my magnet link", it worked like a charm.

So there you have it; wget-like torrent downloading, just 2 commands away from any reasonably up-to-date modern system.

A few things that I've noticed so far: It downloads the torrent to your current directory by default, so make sure you are where you want it to go before running lftp. The person on stack overflow who wrote about this did mention that -c will background the process after the torrent is finished; the background process will seed. I'm not sure to what limit, if any at all, though I'm assuming 1.0.

I hope this helps if you just need to quickly get one torrent and don't feel like installing and setting up a persistent bit torrent daemon.

Comments