Rtorrent: variable use in rtorrent.rc

Created on 28 Jan 2016  路  15Comments  路  Source: rakshasa/rtorrent

can custom variables be used in rtorrent.rc ?
something like bash variables?

All 15 comments

I check it.
tthank you.
BTW does rtorrent have queue ability? like a download queue ?

I looked at the link but it is a nit short and seems that it is incomplete.
and it doesn't say how to use this variables.
should add $ at the beginning of them like bash.can I concatenate the text one together. and so on.
wish it was more documented
is there any documentation that is more or less complete?
the wiki here is not.

for example this doesn't work.
custom_di1 = /dl/1
says:
rtorrent: Error in option file: ~/.rtorrent.rc:1: Command "custom_di1" does not exist.

  1. " does rtorrent have queue ability? like a download queue ?"
    Not really. You have to implement it by yourself. Take a look at my last comment in here: https://github.com/rakshasa/rtorrent/issues/311
    I have also created a better queue shell script that I haven't uploaded to github yet. If you're interested I can do it.
  2. scripting:
    Take a look at my configs there are couple of good examples what you can do and how (I'd like to thank to @pyroscope who created the original rtorrent-ps.rc config file):
    https://github.com/chros73/rtorrent-ps/blob/master/ubuntu-14.04/home/chros73/.rtorrent.rc
    https://github.com/chros73/rtorrent-ps/blob/master/ubuntu-14.04/home/chros73/.pyroscope/rtorrent-0.9.5.rc

If you don't understand something just ask :)

Complete docs will happen when "the community" (if there actually is one) steps up and creates them.

I looked at the configs provided but aren't they specific to rtorrent-ps ?
what about plain rtorrent?
do the throttle_* options works for plain rtorrent?

by the way , is there a way for me to tell rtorrent to change the listening port based on the local ip?
so that I can use it on my laptop both with wifi and lan NIC when I want to?
so how do I set open ports to work for both for wifi and lan ?

"I looked at the configs provided but aren't they specific to rtorrent-ps ?"
"do the throttle_* options works for plain rtorrent?"
If you're talking about mine then they are separated: what inside in .rtorrent.rc is for rtorrent only.

"how do I set open ports to work for both for wifi and lan ?"
It can be done easily by using external shell scripts. First we create a shell script that will give back the possible port numbers (/home/chros73/bin/getPortNumber.sh):

#!/bin/bash
IPNUMBER=$(ifconfig | sed '/inet\ /!d;s/.*r://g;s/\ .*//g' | grep -v 127.0 | cut -d"." -f4)
if [ "$IPNUMBER" -eq 83 ]; then
    echo -n 60083;
else
    echo -n 60084;
fi

And in rtorrent config you need the following (this will only run once when rtorrent is started):

# create a method called pyro.bin_dir that will store the full path for our script dir
method.insert = pyro.bin_dir, string|const, "$cat=/home/chros73/bin/"
# create a method called get_port_number that will store the output of the script which is a string (only a number)
method.insert = get_port_number, simple|value|private, "execute.capture=\"$cat=$pyro.bin_dir=,getPortNumber.sh\""
# concatenate them together to get something like: "60084-60084"
network.port_range.set = "$cat=$get_port_number=,-,$get_port_number="

I am not familiar with PyroScope. as far as I know it is the tools for extending rtorrent functions ,right?
but in your rtorrent it has a PyroScope setting. so that needs the rtorrent-ps not rtorrent right?

for the second question ,you got half of my point correct.
I asked if rtorrent can change its port based on the local ip when it is running, as in middle of its running it I connected to wifi then rtorrent check the local IP (not real time but schedule every 1 min maybe) and change its port .

BTW, please stop using the "$foo=bar" options when executing commands and such as that is supposed to be deprecated, and has caused a lot of issues with parsing.

https://github.com/rakshasa/rtorrent/wiki/COMMAND-Execute
https://github.com/rakshasa/rtorrent/wiki/COMMAND-Scheduling

Basically atm you should encapsulate commands in brackets '{}', however currently you can also use parentheses '()'. Double parentheses mean they don't get executed at that point, but are passed as a 'list' argument.

Both brackets and parentheses currently cause the commands to execute, however the goal was to make the parentheses just create lists while the brackets were executable. But that's far in the future. Just move away from using the old 'foo=bar,arg1,arg2,etc'.

Also as shown above you can create variables, it's just not documented. Some help with the github wiki would not hurt.

@rezad1393:

  1. "but in your rtorrent it has a PyroScope setting. so that needs the rtorrent-ps not rtorrent right?"
    Well, it depends how you want to organize it. In the previous example pyro.bin_dir was just a name from my config, but you can name it as you want (it just points to a directory where our scripts are). And since we use this 'variable' in our main rtorrent config we can leave it there.
  2. "I asked if rtorrent can change its port based on the local ip when it is running"
    No, you can't do it on the fly: you have to restart rtorrent for that.

@pyroscope: Thanks, I saw your commit and pull request as well. But sometimes I want to create variables in rtorrent not system wise, e.g.: https://github.com/chros73/rtorrent-ps_setup/blob/master/ubuntu-14.04/home/chros73/.rtorrent.rc#L79

@rakshasa: thanks for the explanation. Have you only talked about those 2 commends? (execute, schedule)
Because I tried out with cat (which was heavily used in the example above) and I can't concatenate more than 1 strings in any other way but as I've written in the above example. So, this is working: print=$foo=

method.insert = foo, simple|value|private, "cat=x,-,y"

How would you rewrite this in the appropriate way?

Because of this I only write the above schedule line in one of the following ways:

method.insert = get_port_number, simple|value|private, "execute.capture=\"$cat=$pyro.bin_dir=,getPortNumber.sh\""
method.insert = get_port_number, simple|value|private, "execute.capture={\"$cat=$pyro.bin_dir=,getPortNumber.sh\"}"
method.insert = foo, string|private, (cat,x,-,y)
method.insert = bar, string|private, "$cat=x,-,y"
print = (foo)
print = (bar)

You can't define something both as a 'simple' and a 'value'/'string'. Probably should add a check for that.

@rakshasa Oh, thanks, so I mixed up simple and value. That means I have to fix my config files as well.
"Both brackets and parentheses currently cause the commands to execute, however the goal was to make the parentheses just create lists while the brackets were executable."
Well, the below example doesn't work with brackets {} (in any way), so it's working somehow differently.
method.insert = foo, string|private, (cat,x,-,y)

These new syntax is a black box for me, I more like the deprecated one. :)

Well, the old syntax is a nightmare to support while the new one is basically a version of lisp.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dirtycajunrice picture dirtycajunrice  路  6Comments

Bystroushaak picture Bystroushaak  路  4Comments

crazy-max picture crazy-max  路  4Comments

rezad1393 picture rezad1393  路  6Comments

MrSorcus picture MrSorcus  路  5Comments