~/.rtorrent.rc
rather non-standard, there is no normal documentation, so usually the setup is reduced to searching and copying (an attempt to change something in them except constants / paths to directories usually fails) ready-made recipes or is generally limited to editing constants in basic configuration.~/.rtorrent.rc
to a more modern one and view migration instructions .ack CMD2
(well, or the old fashioned way, grep -r CMD2
)Ctrl-X
, after which you can enter any command, for example: command> print="Hello ",World!
(22:13:39) Hello World!
l
, exit the log viewing screen by pressing the spacebar.~/.rtorrent.rc
is not the config file . Yes, it looks like, but this is just a dangerous illusion. In fact, this is a program : a sequence of commands (this is an official term, but I will continue to call them functions , so more familiar and in fact more correct), and actively using the transfer of some commands (along with their own parameters) parameters to others (hello, callback) and in the configs - only you lacked complete happiness!), with several levels of nesting and different screening options. You can (and will) have to create your own functions — it helps a lot to reduce the number of nesting levels and the resulting shielding difficulties. throttle.global_down.max_rate.set_kb = 10000
throttle.global_down.max_rate.set_kb(10000)
=
after the name of the first command in the line (it doesn't matter if it is a config file string or a quoted string in the middle of a config file string);
separating commands in a line describing the body of a new function # , func() func= # , func("param1","param2") func=param1,param2
,
or ;
(to use quotes is always - for clarity - difficult, because very often this parameter is already inside a line containing several commands, so you have to use quotation escaping and visibility as a result will only get worse). func="first param, with special chars","second;param"
$
in front of the function name: # : system.hostname= print=system.hostname= # : system.hostname= print="system.hostname=" # : powerman.name print=$system.hostname= # : powerman.name print="$system.hostname="
print
function takes one parameter: the string "system.hostname="
. In the third and fourth print
, the parameter receives the result of the function system.hostname
without parameters: the string "powerman.name"
.print
function displays all its parameters, and if one of them is a function call, which also has parameters, it is necessary to separate which parameters relate to print
and which to another function (in fact, this is not a very urgent problem, since most functions rtorrent parameters either do not accept or accept one): # : one 27 23:50:51 EEST 2014-utwo print=one,$execute.capture=date,-u,two # : one 27 20:51:05 UTC 2014two print=one,"$execute.capture=date,-u",two
execute.capture
function executes any system command (via sh) and returns what this command outputs to STDOUT. Therefore, it can take any number of parameters (command name and parameters for it). As you can see in the first variant, it took only one parameter (and called date
) and the rest (-u, two) went to print
. And in the second, we explicitly indicated which parameters belong to execute.capture
, so it caused date -u
and print
only got the last parameter (two).date
system command completes the output with a newline, so the rest of the print
parameters are already displayed on another line, and rtorrent shows this not very clearly, even in the log. Therefore, in order for the example to work, you need to replace the date
command with a variant that does not print a line break, for example, put in ~/bin/date
: #!/bin/bash echo -n `/bin/date "$@"`
(( ))
passed, where the function name is the first string and the rest of its parameters . # func() : # - callback- func1() # - "param2" func=func1=,param2 # func() : # - callback- func1("param11","param12") # - "param2" func="func1=param11,param12",param2 # , func=((func1,param11,param12)),param2
func1
in the parameters must also be passed callback, then you need to either use different shielding styles (quotes / brackets), or shuffle quotes inside the quotes, or use nested brackets. # func1() param11 # callback func2("param21","param22") : func="func1=\"func2=param21,param22\",param12",param2 func="func1=((func2,param21,param22)),param12",param2 func=((func1,((func2,param21,param22)),param12)),param2 func=((func1,"func2=param21,param22",param12)),param2
{ }
. Where and for what it should be applied I did not understand yet.method.insert
function. The first parameter is the name for the new function, the second is its type (usually simple
, but if you need to create not a function but a variable, then you need to use the types value
, bool
, string
; you can also make a function / variable private
and const
and not only - unfortunately deal with these features need to source), the third line with the function body. Unlike the lines with callbacks described above, in this line you can send several commands through ;
but you cannot use the separator (( ))
. # : method.insert = newfunc, simple, "func=param1,param2;func1=;func2=" # : newfunc=
argument.0=
... argument.3
. method.insert = hello, simple, "print = \"Hello \", $argument.0=, !" # : Hello Powerman! hello=Powerman
# some.var "value" some.var.set = value some.set_var = value some.var = value # some.var $some.var= $some.var.get= $some.get_var=
method.insert
for the sake of creating a pair of variables, there are ready-made functions that allow you to work with variables attached to a specific torrent (which allows you to save information on each torrent separately): # var value d.custom.set = var, value # var $d.custom=var
# 5 d.custom1.set = value1 d.custom2.set = value2 d.custom3.set = value3 d.custom4.set = value4 d.custom5.set = value5 # 5 $d.custom1= $d.custom2= $d.custom3= $d.custom4= $d.custom5=
d.
associated with a particular torrent, and each torrent has its own values for these variables. Similarly, functions starting with d.
- they also operate on the current torrent. Nevertheless, I think that this is a feature of the implementation of built-in functions, and for user functions and variables, the presence or absence of d.
the name does not make them magically related to the current torrent (however, I did not check it).schedule
transmitted inside (( ))
and not " "
, then the parameters for this callback are also set inside nested (( ))
for some reason are treated as the result of the function, and not its transfer as a callback: schedule id,1,1, ((print, ((directory.default)))) # schedule id,1,1, "print = $directory.default="
load.start
or ui.current_view.set
) - their execution needs to be postponed through the schedule
, and the start time should be greater than 0. Probably this is due to the fact that when rtorrent is started, by the time commands from the config file are executed, not all data structures have been correctly initialized. print =
$cat =
print
, only returns the string instead of outputting it to the log). $argument.0= $argument.1= $argument.2= $argument.3=
method.insert = _, simple, "; "
method.insert
and method.set_key
can a sequence of several commands be passed through ;
- all other functions where you can send commands take them either one by one or as a list (eg load.normal
and load.start
). method.set_key = event.download., _, "; "
: inserted
, inserted_new
, inserted_session
, erased
, opened
, closed
, resumed
, paused
, finished
, hash_done
, hash_failed
, hash_final_failed
, hash_removed
, hash_queued
. Why the _
not clear (it can probably be checked through method.has_key
and method.list_keys
but it’s not clear where this might be useful), but it is easy to guess that it should be unique. schedule = _, , , schedule_remove = _
, the main tool for automation rtorrent. Values for the
and the
can be set either in seconds or in the format ::
(if the
set to 0, it will be executed once). For commands that must be executed when rtorrent is started, the value for the
usually set to 5 - it is likely that rtorrent has time to fully start and the bugs I mentioned above haven't occurred. load.normal = __torrent_(), load.start = __torrent_(),
schedule
to automatically download files added to the specified directory. load.start
automatically starts downloading the file after adding. execute = _, execute.capture = _, execute.nothrow = _, execute.nothrow.bg = _,
execute.capture
returns the output of this command, execute.nothrow
ignores the error of the running command, execute.nothrow.bg
runs the program in the background. if = , __, __ branch = _, __, __
if
and branch
is how the condition is defined: as a value ( $func=
) or as a command ( func=
). In addition, instead of the __
if-a- __
you can set the following condition and add two more command parameters, etc. false= not = and = or = equal = less = greater =
if
and branch
functions, less
and greater
are used to set up different sorts. import = -
start_tied= stop_untied= close_untied= remove_untied=
schedule
and load.start
). Curiously, rtorrent does not use this file for download, but a copy of it, which it saves to its session.path
directory. Accordingly, stop_untied
, close_untied
and remove_untied
when executed, determine what to do with the torrent file in the session.path
directory if the original torrent file associated (tied) with it has been deleted. What the start_tied
team is doing, I still do not understand. $d.base_filename= $d.base_path= $d.creation_date= $d.directory= $d.load_date= $d.name= $d.tied_to_file=
d.directory
is the directory where the torrent will be d.tied_to_file
, d.tied_to_file
name of the original (not from the session.path
) .torrent file, d.name
the file or directory the pumped out by this torrent, etc. $d.complete=
d.close= d.create_link = , , d.delete_link = , , d.delete_tied= d.erase= d.open= d.pause= d.resume= d.save_full_session= d.start= d.stop=
value can be base_path
, base_filename
and tied
and defines the directory for the symlink (from d.base_path
, d.base_filename
or d.tied_to_file
), the
and
are added to the name and can be empty. d.multicall
/mnt/torrent/
, /mnt/torrent/serials/
and /mnt/torrent/music/
it should be:/mnt/torrent/music/
directory should start immediatelyschedule = watch_directory_1, 5, 5, ((load.normal, /mnt/torrent/*.torrent, "d.custom.set = watchdir, / mnt / torrent", "d.directory.set = $ d.custom = watchdir ")) schedule = watch_directory_2, 5, 5, ((load.normal, /mnt/torrent/serials/*.torrent, "d.custom.set = watchdir, / mnt / torrent / serials", "d.directory.set = $ d.custom = watchdir ")) schedule = watch_directory_3, 5, 5, ((load.start, /mnt/torrent/music/*.torrent, "d.custom.set = watchdir, / mnt / torrent / music", "d.directory.set = $ d.custom = watchdir "))
[rutracker.org].t4788972.torrent
automatically renamed to (The Listener) (Season V, 2014, WEB-DL 720p) [FOX].torrent
)---
if it has not yet downloaded or +++
if it has already downloadedmethod.insert = d.renamed_suffix, simple, "if = $ d.complete =, +++, ---" # - WORKAROUND: extra / at beginning needed because $ d.tied_to_file = begins with // method.insert = d.renamed_file, simple, "cat = /, $ d.custom = watchdir, /, $ d.name =,., $ d.renamed_suffix =, .torrent" method.insert = d.rename_file, simple, "execute = mv, -, $ d.tied_to_file =, $ d.renamed_file =; d.tied_to_file.set = $ d.renamed_file =" method.insert = d.safe_rename_file, simple, "branch = ((equal, d.tied_to_file =, d.renamed_file =)),, d.rename_file =" method.set_key = event.download.inserted_new, rename_loaded, d.safe_rename_file = method.set_key = event.download.resumed, rename_resumed, d.safe_rename_file = method.set_key = event.download.finished, rename_finished, d.safe_rename_file =
session.path
also needs to be deleted and this torrent removed from rtorrent.# Watch a directory for torrents and remove those that have been deleted. schedule = watch_untied, 5, 5, (((remove_untied))
# Notify when download finished method.set_key = event.download.finished, notify_me, "execute = ~ / bin / rtorrent_finished, $ d.name ="
6
manually).# Set default view schedule = default_view, 1, 0, ui.current_view.set = incomplete
less=
).method.set_key = event.download.inserted_new, loaded_time, "d.custom.set = tm_loaded, $ system.time =; d.save_full_session =" view.sort_new = incomplete, less = d.custom = tm_loaded view.sort_current = incomplete, less = d.custom = tm_loaded
Source: https://habr.com/ru/post/238413/
All Articles