Torrent management: Process finished torrents

From Bitpost wiki

Here's where we have the most fun. rtorrent has done all the work for us to grab our torrents, moving completed files into [download/torrents/finished]. Now we'll write some script magic to organize our downloads, without interrupting rtorrent seeding.

Let's review our directory layout:

download/torrents/   actively downloading torrents and files
  finished/          files that have finished downloading
  archived/          actively seeding torrents of archived files
    symlinks/        symlinks to files that have been archived
    offline/         offline torrents - move back to archived to auto-restart

We already have the first two directories working. Here's the next goal: move finished files to the proper location, according to the content. IMHO, if you are a reasonably sane person, you don't want all your media jammed into one directory. You want to keep your media organized, preferrably in a central location on the network. So let's get organized! We'll use some regex magic - don't worry, it's not too hard. In true hacker fashion, we'll use a mixed bag of scripts that I stole whenever possible, and wrote only when necessary. I'll try to give credit where due!  :>

Steps:

  1. Scan the finished directory for the top-level file or directory of newly-completed downloads
  2. For each one we find, scan the torrents directory for a matching .torrent file
  3. Examine each file-dir/.torrent pair to determine where it should be archived
  4. Move the .torrent file to the archived/backup directory (this temporarily stops seeding)
  5. Move the files to the correct archive location on the network (this may take some time...)
  6. Create a symlink to the files under archived/symlinks
  7. Move the .torrent in backup into the archived dir, while giving it a completed hash
  8. rtorrent will immediately seed the .torrent file using the newly archived files

Scripts:

Installation:

  1. Put all scripts in a script directory accessible by cron
  2. Run the rss script in cron every 15 minutes or so
  3. Run the main script in cron every half hour or so
  4. Check your email! cron will tell you when you have gotten a new .torrent, and when it is archived and available
  5. To put archived torrents offline, move the .torrent file from archived to offline; move it back to seed again


<- Back to main article