rakshasa / rtorrent

rTorrent BitTorrent client
https://github.com/rakshasa/rtorrent/wiki
GNU General Public License v2.0
4.15k stars 414 forks source link

[question] Automove files after finished download, only if label is a certain one, or ones. #1207

Closed Runisco closed 1 year ago

Runisco commented 1 year ago

Right now I have the followin in my rtorrent.rc file:

schedule = watch_directory_1,5,5,"load.normal=~/downloads/autodownload/Stuff/*.torrent,d.set_custom1=Stuff"
method.insert = d.get_finished_dir,simple,"cat=~/downloads/,$d.custom1="
method.set_key = event.download.finished,move_complete,"d.directory.set=$d.get_finished_dir=;execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.base_path=,$d.get_finished_dir="

But is there a way to augment this to include a label check, so that the automove ONLY moves ones with a certain label, but leaves all other labels alone unless I add it to the check in the rtorrent.rc file?

kannibalox commented 1 year ago

The label is in d.custom1, so with a little bit of fanciness you can add a conditional (split into two methods here):

method.insert = d.automove_path, simple \
  "execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.base_path=,$d.get_finished_dir="
method.insert = d.maybe_automove_path, simple, \
  "branch = ((equal, ((d.custom1)), ((cat, \"LABEL_TO_MATCH\")))), \
  ((d.automove_path))"
method.set_key = event.download.finished,move_complete,"d.maybe_automove_path="

If you want to add more labels, you can just copy and paste the last two lines:

method.insert = d.maybe_automove_path2, simple, \
  "branch = ((equal, ((d.custom1)), ((cat, \"LABEL_TO_MATCH_2\")))), \
  ((d.automove_path))"
method.set_key = event.download.finished,move_complete,"d.maybe_automove_path2="