[SOLVED] bash script triggered by execute plugin not working

Suggest, post, or discuss plugins for Deluge
Post Reply
deckoff
Member
Member
Posts: 18
Joined: Sat Feb 25, 2012 12:03 pm

[SOLVED] bash script triggered by execute plugin not working

Post by deckoff »

Here is what I try to do - a a script which will copy the torrent to another location, based on the torrent label.
I use execute and label default plugins.

The script will correctly guess the label of the torrent. As you can see below, the script will correctly log the variables, I use for input file and output dir. The exact command, that is produced in the log file, will copy what I want where I want. It seems, though, in the script, the cp command will not trigger?? What might be the problem?

The problem script - complete (it is invoked ny another script, wrapper,

Code: Select all

#!/bin/bash

torrentid="$1"
torrentname="$2"
torrentpath="$3"

LABEL=$(/home/***/Desktop/getLabel.py $torrentid)

        # echo $torrentname $torrentpath  "was downloaded"  >> /home/****/lastxfer.txt


# American Idol 11
if [ $LABEL == "americanidol" ]; then
	copyname="'"$torrentpath"/"$torrentname"'"
	echo  cp $copyname "'/home/***/Desktop'" >> /home/****/lastxfer.txt
	# sleep 10
	cp $copyname "'/home/***/Desktop'"
	# gnome-terminal --execute '/home/deckoff/Desktop/CPSCRIPT' $copyname '/home/***/Desktop'
fi
Scripts in use:
getLabel.py

Code: Select all

#!/usr/bin/python

import sys
from deluge.ui.client import client
from twisted.internet import reactor

# Set up the logger to print out errors
from deluge.log import setupLogger
setupLogger()

d = client.connect()

torrent_id = sys.argv[1]

def on_connect_success(result):
    def on_get_torrent_status(torrent):
        print torrent["label"]
        client.disconnect()
        reactor.stop()

    client.core.get_torrent_status(torrent_id, ["label"]).addCallback(on_get_torrent_status)

d.addCallback(on_connect_success)

def on_connect_fail(result):
        print result
        reactor.stop() 

d.addErrback(on_connect_fail)

reactor.run()
wraper

Code: Select all

#! /bin/bash
/home/****/Desktop/DS/complete "$1" "$2" "$3" &
Last edited by johnnyg on Fri Mar 02, 2012 7:48 pm, edited 2 times in total.
Reason: problem is solved
deckoff
Member
Member
Posts: 18
Joined: Sat Feb 25, 2012 12:03 pm

Re: CP in bash script triggered by execute plugin not worki

Post by deckoff »

Me bad - the corrected script:

Code: Select all


#!/bin/bash

torrentid="$1"
torrentname="$2"
torrentpath="$3"

LABEL=$(/home/****/Desktop/getLabel.py $torrentid)



if [ $LABEL == "americanidol" ]; then
	cp /home/deckoff/Downloads/$torrentname '/media/MyBookLive/Shared Videos/TV Shows/*****/Season 11'
	echo  cp /home/deckoff/Downloads/$torrentname "'/home/***/Desktop'" >> /home/****/lastxfer.txt
fi
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: CP in bash script triggered by execute plugin not worki

Post by johnnyg »

So is the corrected script still not working?

As an aside, wouldn't it be better to use the move completed feature of labels instead of making a copy?
deckoff
Member
Member
Posts: 18
Joined: Sat Feb 25, 2012 12:03 pm

Re: CP in bash script triggered by execute plugin not worki

Post by deckoff »

No, it is working :) I cant find how to mark the thread as solved:) I just posted for others to see. I messed up with some quotation marks :)
I dont want to move the torrent, cos I cp them to NAS to be used by an XBMC machine, and this will slow download. Sometimes I re-name, edit tags, etc. BTW, I just found the label options, thank you :)
Not quite on the topic - can I use the auto label based on regex. Cant find any info how to use the label plugin
Last edited by deckoff on Sat Mar 03, 2012 8:43 pm, edited 1 time in total.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: CP in bash script triggered by execute plugin not worki

Post by johnnyg »

deckoff wrote:Not quite on the topic - can I use the auto label based on regex. Cant find any info how to use the label plugin
Labels can be automatically applied based on tracker (it just does a simple substring check nothing fancy involving regex).
You could however write an execute script (for the added event) which automatically applies a label.
I'd recommend creating a new thread if you want to discuss it more.
Post Reply