Hinrik Örn Sigurðsson

NAME

irctor-queue - Log RTorrent actions to a file

DESCRIPTION

This program is meant to be called by RTorrent's event handlers. It logs actions to a log file based on the arguments it receives.

Optionally, when RTorrent tells it that a torrent has finished, irctor-queue can inspect the downloaded content and call unrar(1) in these situations:

  • The content is a single rar file. If the rar archive contains more than one file/directory, a directory will be created to contain them, with the same name as the archive without the ".rar" suffix)

  • The content is a directory with a rar archive that contains a single file/directory

  • The content is a directory containing CD[1-9] subdirectories which have rar archives (containing only a single file/directory each)

POE::Component::IRC::Plugin::RTorrentStatus follows the log file created by this program and announces various events on IRC.

CONFIGURATION

.rtorrent.rc must have the following lines in it. /tmp/torrentlog is the log file it will write to. Change it if you want to keep it elsewhere. Note that irctor_finished needs to know where you keep your completed files (last argument).

 # irctor-queue hooks, with unrar
 system.method.set_key = event.download.inserted_new,irctor_inserted_new,"execute=irctor-queue,/tmp/torrentlog,inserted_new,$d.get_name=,$d.get_size_bytes=1,$d.get_tied_to_file=1"
 system.method.set_key = event.download.hash_queued, irctor_hash_queued, "execute=irctor-queue,/tmp/torrentlog,hash_queued, $d.get_name=,$d.get_size_bytes=1,$d.get_completed_bytes=1,$d.get_tied_to_file=1,$d.get_complete=1,$d.get_down_total=1"
 system.method.set_key = event.download.finished,    irctor_finished,    "execute=irctor-queue,/tmp/torrentlog,finished,    $d.get_name=,$d.get_base_filename=1,/home/leech/torrent/complete"
 system.method.set_key = event.download.erased,      irctor_erased,      "execute=irctor-queue,/tmp/torrentlog,erased,      $d.get_name=,$d.get_size_bytes=1,$d.get_completed_bytes=1,$d.get_up_total=1,$d.get_ratio=1"

Note: If you don't get any "Finished" events, it's probably because you have check_hash = no in your RTorrent config. Remove it. If you have any other problems, you should add e.g. log.execute = /tmp/exec.log to store any errors RTorrent experiences when executing event hooks.

With unrar functionality

If wou want the unrar functionality, you must edit the irctor_finished line by adding a 1 argument to the end:

 system.method.set_key = event.download.finished,    irctor_finished,    "execute=irctor-queue,/tmp/torrentlog,finished,    $d.get_name=,$d.get_base_filename=1,/home/leech/torrent/complete,1"

If you have an RTorrent hook which moves completed downloads to some directory, make sure the name of that hook comes before (according to ASCII sorting) the name of the irctor_finished hook. This is necessary because RTorrent executes hooks in alphabetical order.

Caveats

If an unrar operation fails we try to report the error message, but in some cases an empty message will be delivered. One such case is when unrar fails due to reaching the user's disk quota, because the error message will be delivered to the process' controlling terminal, which we don't catch (yet).

AUTHOR

Hinrik Örn Sigurðsson, hinrik.sig@gmail.com

LICENSE AND COPYRIGHT

Copyright 2010 Hinrik Örn Sigurðsson

This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.