[BOUNTY] Simple rutorrent plugin to send name, path and label to shell script

jith45

Member
May 25, 2018
960
0
16
Hi!

I have a request for a simple plug-in that will give me a new option when I right-click on a torrent. This button (call it "Send to Filebot") would trigger a shell script with three arguments (torrent path, torrent name, torrent label).

The purpose is to load my rtorrent-postprocess.sh script (just like when it is triggered by the rtorrent.rc when a download is completed) shown below:

rtorrent.rc
Code:
system.method.set_key=event.download.finished,filebot_amc,"execute={/*****/rtorrent-postprocess.sh,$d.get_base_path=,$d.get_name=,$d.get_custom1=}"
rtorrent-postprocess.sh
Code:
#!/bin/bash
log_file="log_file.log"
echo "---------------------------------------------------" >> $log_file
echo "ProcessID: $$" >> $log_file
echo "Starting script at: $(date)" >> $log_file
echo "TORRENT_PATH: $1" >> $log_file
echo "TORRENT_NAME: $2" >> $log_file
echo "TORRENT_LABEL:$3" >> $log_file

TORRENT_PATH=$1
TORRENT_NAME=$2
TORRENT_LABEL=$3
{
if [ $TORRENT_LABEL = TV ] || [ $TORRENT_LABEL = Movies ] || [ $TORRENT_LABEL = New ] ;
then
echo "Label is TV, Movies or New"
bash ~/filebot/filebot.sh -script fn:amc --output "/*****/private/rtorrent/complete/" --log-file amc.log --action hardlink --conflict override --def "movieFormat=/*****/rtorrent/complete/Movies/{n.upperInitial().space('.')}.{y}.{source}.{vf}.{vc}{'-'+group}/{fn}" --def unsorted=y -non-strict --def music=n artwork=y "ut_dir=$TORRENT_PATH" "ut_kind=multi" "ut_title=$TORRENT_NAME" "ut_label=$TORRENT_LABEL" &
elif [ $TORRENT_LABEL = Games ]
then
echo "Label is Games"
else
echo "Label is NOT TV, Movies, Games or New"
fi
}
Bounty: £10 via PayPal!

Thanks for your help! Let me know if you have any questions or need any more info.
 

shwetha17

Member
May 24, 2018
785
0
16
Check attach.

Points.
1) Set full path to your script in the plugin's conf.php. By default plugin call script 'test.sh', this script simply print passed parameters to the file '/tmp/test.lst'.
2) You may run your command for several selected torrents.
3) If torrent wasn't opened since last start of rtorrent, then it's basepath is empty. Plugin will not call your script for such torrents.
4) d.get_custom1 contains torrent's label in the encoded form. Plugin decode it before passing to your script. Your line in rtorrent.rc pass encoded label.
 

jith45

Member
May 25, 2018
960
0
16
Many thanks shwetha- I am currently away but will test it out on Tuesday and let you know!
 

jith45

Member
May 25, 2018
960
0
16
shwetha

The plug-in has created the 'Send to Filebot' button on my rutorrent.

However, I have tested it both with the test.sh and also with the absolute path of my own script, and neither appear to even generate the log file (which is unhelpful, I know). Any ideas what it could be?

On point 3), do you mean rtorrent or rutorrent? If it's rutorrent, that's no problem at all. However, restarting rtorrent every time after I want to send a new torrent to filebot isn't quite ideal as it is constantly running and the function will usually be used for new torrents coming in - is there any way around this?

Thanks again mate!
 

shwetha17

Member
May 24, 2018
785
0
16
However, I have tested it both with the test.sh and also with the absolute path of my own script, and neither appear to even generate the log file (which is unhelpful, I know).


You should check web-server's error log.


Any ideas what it could be?


For example, your forgot to set executable attribute to the .sh file.


On point 3), do you mean rtorrent or rutorrent? If it's rutorrent, that's no problem at all. However, restarting rtorrent every time after I want to send a new torrent to filebot isn't quite ideal as it is constantly running and the function will usually be used for new torrents coming in - is there any way around this?


I mean torrent. Try to add .torrent with a checked option "Don't start the download automatically". Restart rtorrent. Check interface. You will see an empty field in the section 'Save As' on the 'General' tab. This is because rtorrent doesn't open files of this torrent and, as result, base_path is unknown.
Your line in .rtorrent.rc from the your first post will not work too with such torrents.
 

jith45

Member
May 25, 2018
960
0
16
I confirm that I have made the test.sh executable & there is still nothing in the web servers error logs (which also does not have anything)... sad.gif
 

Attachments

shwetha17

Member
May 24, 2018
785
0
16
OK, what next? I need an access to your system for saying something.
ruTorrent + SSH access.

If this is not possible, then let's finish with this.
 

jith45

Member
May 25, 2018
960
0
16
Hi shwetha, sorry I've been away for so long.

Are you still willing to try make this work? If so, I will pm the ssh and any other info you may need!