Torrent management: Process finished torrents: Difference between revisions
No edit summary  | 
				No edit summary  | 
				||
| Line 31: | Line 31: | ||
# Check your email!  cron will tell you when you have gotten a new .torrent, and when it is archived and available  | # Check your email!  cron will tell you when you have gotten a new .torrent, and when it is archived and available  | ||
# To put archived torrents offline, move the .torrent file from archived to offline; move it back to seed again  | # To put archived torrents offline, move the .torrent file from archived to offline; move it back to seed again  | ||
[[Automated_torrent_management_in_linux|<- Back to main article]]  | |||
Latest revision as of 17:37, 24 March 2011
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:
- Scan the finished directory for the top-level file or directory of newly-completed downloads
 - For each one we find, scan the torrents directory for a matching .torrent file
 - Examine each file-dir/.torrent pair to determine where it should be archived
 - Move the .torrent file to the archived/backup directory (this temporarily stops seeding)
 - Move the files to the correct archive location on the network (this may take some time...)
 - Create a symlink to the files under archived/symlinks
 - Move the .torrent in backup into the archived dir, while giving it a completed hash
 - rtorrent will immediately seed the .torrent file using the newly archived files
 
Scripts:
- Torrent management: main script (process_finished_torrents.pl)
 - Torrent management: archive script (archived_finished_torrent)
 - Torrent management: torrent parser script (extract_torrent_dir.php)
 - Torrent management: rtorrent seed hash script (rtorrent_fast_resume.pl)
 
Installation:
- Put all scripts in a script directory accessible by cron
 - Run the rss script in cron every 15 minutes or so
 - Run the main script in cron every half hour or so
 - Check your email! cron will tell you when you have gotten a new .torrent, and when it is archived and available
 - To put archived torrents offline, move the .torrent file from archived to offline; move it back to seed again