*** What is Bittorrent? ***
Bittorrent is a distributed P2P file sharing client, used for "swarming [big] downloads across unreliable networks". When you download a file using Bittorrent, you also provide the parts you already downloaded for others to upload. You have to provide just as much upload as you've downloaded, so that everyone gets treated on an equal basis.
Advantages: you can get extremely high download rates and the file gets constantly checked for errors, so it will be extremely unlikely you will end up with a broken download. A 200MB-file could very well be finished within a couple of hours.
Disadvantages: This is mostly used for the newer/newest stuff, so chances are after a while you won't find previous versions of a file/series because everyone already downloaded it. This is why Bittorrent is mostly used for getting the latest movie/anime from the net. Also a lot of Linux ISO's are available. More info: http://bitconjurer.org/BitTorrent/
*** END ***
One way to retrieve bit torrents is to use a GUI based client, like the default btdownloadgui.py or something more fancy like Azureus. (if this post gets stickied in the FAQ, I'll volunteer to add details about gui based downloading).
I wanted a way to start and control torrent downloads remotely (understand "from work") over ssh, so I looked at the command line version of bittorrent. This worked well however the torrent would abort if I closed the ssh session, or I wouldn't have access to the session once I got home, so I looked into the "screen" command. Combining the two provided a solution that perfectly met my needs and I'm outlining it here.
First you need to install the bittorrent command line clients: urpmi bittorrent
You may also have to install Python, although it came installed with my Mandrake10 Powerpack so I didn;t go through that step.
The bittorent package provides 2 python scripts: btdownloadheadless.py and btdownloadcurses.py.
You can also install bittorrent-gui (urpmi bittorrentgui) to install the script downloadgui.py which is what gets launched by default when you click on a .torrent file in your browser and provides a very basic gui interface (basically the same as with the default client under Windows)
btdownloadheadless.py outputs results periodically in the console (every .5s by default!)
btdownloadcurses.py uses the curses library to "redraw" the current status of the download using characters.
btdownloadcurses.py suits my style best, so it is what I will be using here, although you can use the same recipe for btdownloadheadless.
First try out btdownloadcurses on the command line (either the console or an ssh session) to see what it does. locate the URL to a torrent file, say http:/this_is_a_url/MyTestTorrent.torrent and simply type btdownloadcurses.py http:/this_is_a_url/MyTestTorrent.torrent
You should see something like this:
------------------------------------------------------------------------------ | file: MyTestTorrent | | size: 527,543,812 (503.1 MB) | | dest: /home/papaschtroumpf/torrents/MyTestTorrent | | progress: ###_______________________________________________________________ | | status: finishing in 5:08:28 (5.8%) | | speed: 44.2 KB/s down - 67.3 KB/s up | | totals: 29.4 MB down - 55.0 MB up | | error(s): | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------
since we're running over ssh, there is no need to update the screen so often, it just consumes a bunch of bandwidth, so we could start over by adding the --display_interval command line argument, for example to update the screen only every 5s:
btdownloadcurses.py --display_interval 5 http:/this_is_a_url/MyTestTorrent.torrent
There are lots of other command line options but the defaults appear to work for me. For details on command line options type "man bittorrentgui". This seems to work in mdk 10 (OE at leat) but the man page is not available with all bittorrent rpms so if you don't have it, check out http://annys.eines.info/cgi-bin/man/man2ht...rent-downloader or use google and search for man btdownloadcurses (the command line options are the same for the 3 python scripts)
In particular you may be interested in the --saveas option to rename the file downlaoded and the --limit_upload_rate option if you don't want the torrent to consume all of your available bandwidth.
If you close your console or terminate your ssh session, the torrent will stop downloading because the script will stop. You can always restart where you left off by re-issuing the command above, but there is a better way:
Enters the screen command. Basically it allows you to "detach" a screen from the window you started it in, and re-attach it later to the same window or another one.
Simply use "screen" in front of the previous command:
screen btdownloadcurses.py --display_interval 5 http:/this_is_a_url/MyTestTorrent.torrent
You shouln't see any difference from running it without the screen command.
Now press "Ctrl-A" followed by "d": this is the magic key combination to detach btdownloadcurses.py from the current window: the program hasn't stopped, it simply stopped using the console or ssh window.
close your window or you ssh session. If you simply close the ssh or console window without detaching first, the detach operation still occurs automagically.
Now open a new console or ssh session.
Type screen -r this is the command to re-attach the detached screen to your current console: you now see you torrent download is still in progress and has been downloading "behind the scenes".
If you have started several torrents as detached screens, you can type screen -ls to list the detached screens available on your machine. Then type screen -d -r the_screen_name where the_screen_name is one of the names listed by the previous command that you want to re-attach.
There is much more to the screen command, so refer to its (huge) man page if you need more details. There are lots more magic key pressed than "Ctrl-A d", for example "Ctrl-A K" kills the current scren altogether. The key commands can also be remapped if you like.
Finally, it's a lot of typing anda lot to remember so rather than type everything every time, I created an alias in my ~/.bashrc file:
alias gettorrent='screen btdownloadcurses.py --display_interval 5';
then I can just type gettorrent http:/this_is_a_url/MyTestTorrent.torrent at the command line (and since I generally get the URL through cut and paste, it's very little typing).
Note that I have ran into torrents that use a "compact" tracker. bittorrent-3.3 which is installed with mdk 10.0 doesn't support the compact trackers. Google for bittorrent-3.4.2-1mdk and bittorrent-gui-3.4.2-1mdk packages or above.
Hope you found this tip useful.
This post has been edited by papaschtroumpf: 13 September 2004 - 03:53 PM