Rtorrent: Variable use in rtorrent.rc

Created on 2 Jan 2017  Â·  16Comments  Â·  Source: rakshasa/rtorrent

The following rtorrent.rc template (mainly taken from https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template)

method.insert = cfg.basedir,  private|const|string, (cat,"/home/user/rtorrent/")
method.insert = cfg.watch,    private|const|string, (cat,(cfg.basedir),"watch/")
method.insert = cfg.logs,     private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile,  private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"download/")
method.insert = cfg.session,  private|const|string, (cat,(cfg.basedir),"session/")

session.path.set = (cat,(cfg.session))
directory.default.set = (cat,(cfg.download))

schedule2 = watch_start_music,1,10,"load.start=(cat,(cfg.watch),\"dir1/*.torrent\"),d.directory.set=(cat,(cfg.download),\"/dir1\")"

produces

Scheduled command failed: watch_start_music: Junk at end of input.

If the schedule command is changed like that

schedule2 = watch_start_music,1,10,"load.start=(cat,(cfg.watch),\"dir1/*.torrent\"),d.directory.set=\"/home/user/rtorrent/download/dir1\""

It works. It seems that it is not possible to use a variable in d.directory.set

All 16 comments

Scheduled command failed: watch_start_music: Junk at end of input.

This means that you have syntax error in that line.

What about this instead?
schedule2 = watch_start_music,1,10,"load.start=(cat,(cfg.watch),\"dir1/*.torrent\"),\"d.directory.set=(cat,(cfg.download),/dir1)\""

Impressive, it works.
This syntax is for me very weird. Can you explain me how did you find it ?

:) I "found" it via trail and error approach.
You can can take a look at these 3 config files (and the rest of the color configs) if you are interested in scripting: you can do amazing things with rtorrent.
.rtorrent.rc, .rtorrent-config.rc, rtorrent-ps.rc

I'm sure that amazing things can be done with it... the problem is this syntax that is very difficult to handle.

Yes, you're right. And more than that: there are 2 different syntaxes that you can use. The old one (using ") and the new one (using (, )).

This syntax is for me very weird.

Well, not really. As you can see, every command starts and ends with " (using the old syntax) :

  • "load.start=..."
  • "d.directory.set=..."
    And you have to escape starting commands inside of a command: \"

It seems that when I'm using this syntax, my torrents do not start automatically...
It works like if I was using load instead of load_start. Do you think there can be a linked ?

It should be called: load.start not load_start , see here.

Sorry it was a typo...

I am using this example, that you gave me and that is working.

schedule2 = watch_start_music,1,10,"load.start=(cat,(cfg.watch),\"dir1/*.torrent\"),\"d.directory.set=(cat,(cfg.download),/dir1)\""

The only problem is that torrent does not start automatically, I need to use CTRL+S in order to start it.

schedule2 = watch_start_music,1,10,"load.start=(cat,(cfg.watch),\"dir1/*.torrent\"),\"d.directory.set=(cat,(cfg.download),/dir1)\""

I just tried out the very same line (only modified the dir1 and cfg.* entries) and it works as it should: it also starts the download.
Are your cfg entries valid?

Yes my entries seem valid, it's maybe because I'm using rtorrent-ps with pyroscope (It should be the default configuration). I have to investigate a bit more :)

it's maybe because I'm using rtorrent-ps with pyroscope

I'm using it as well :)

Yeah I know, I have read your configuration :)

So I finally solved my problem and it was not really linked with rtorrent as you know :).

It was in fact because of rutorrent... rtorrent was not able to access rutorrent configuration file... (don't ask me why rtorrent needs to read rutorrent configuration file...). I successfully found the solution using the log.execute directive of rtorrent.rc file. The log was displaying a permission denied on that file.

Now everything works well, until the next problem :+1:

@ymvunjq please close this.

BTW, the more readable version of this is…
https://github.com/pyroscope/pyrocore/blob/master/src/pyrocore/data/config/rtorrent.d/categories.rc#L40

@pyroscope @chros73 I believe this is how watch directories should be set up as per the new config?

schedule2 = watch_start_music, 10, 10, ((load.start, (cat, (cfg.watch), "dir1/*.torrent")), (d.directory.set, (cat, (directory.default), "dir1/")))

Please correct me if I am wrong or misguided. Thanks!

@ymvunjq You don't need to define new constant cfg.download, instead define properly and use the existing directory.default. For e.g.:

# You should already have this (don't forget the forward slash):
directory.default.set   = (cat, (cfg.basedir), "download/")

# Then define watch directories like so:
schedule2 = watch_start_music, 10, 10, ((load.start, (cat, (cfg.watch), "dir1/*.torrent"), d.directory.set, (cat, (directory.default), "dir1/")))

Defining another constant is unnecessary clutter. 😜

Yep, if it works ... :)

Defining another constant is unnecessary clutter.

Well, not necessarily :)

Just updated my rtorrent instance after a while, and moving over to the new config. So I haven't tested it, yet. 🤔

UPDATE: Sorry, it doesn't seem to work; so using the old version.

Defining another constant is unnecessary clutter.

I meant more like, "Defining another constant _when it's not necessary_ is unnecessary clutter." Was just a thought though, not advising or anything. 😅

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  4Comments

dirtycajunrice picture dirtycajunrice  Â·  6Comments

RX14 picture RX14  Â·  4Comments

legrostdg picture legrostdg  Â·  5Comments

mrvn picture mrvn  Â·  3Comments