Execute Plugin and Labels

General support for problems installing or using Deluge
darkcircuituk
New User
New User
Posts: 3
Joined: Fri Feb 27, 2015 12:29 pm
OS or Distro: Ubuntu

Execute Plugin and Labels

Postby darkcircuituk » Fri Feb 27, 2015 12:56 pm

Hey all,
I'm a big fan of Deluge, I run it on 4 different machines and it has worked flawlessly up till now. In Ubuntu I am trying to get the deluge Execute plugin to talk nicely with filebot and although the vast majority of the script works great, I am hitting a problem when trying to get the label I specified with the label plugin. Does anyone have any knowledge on how to get the label within a bash script? I blindly hoped that argument 4 might be the label but nope; I have put my script below in-case it helps.

Code: Select all

#!/bin/bash
TORRENT_ID=$1
TORRENT_NAME=$2
TORRENT_PATH=$3
TORRENT_LABEL=$4

filebot -script fn:amc --output "/media/NAS" --log-file filebot.log --action test --conflict override -non-strict --def music=y artwork=n clean=y "seriesFormat=Videos/TV Shows/{n.replace(':','- ')}/Season {s}/{'S'+s.pad(2)}{'E'+e.pad(2)} - {t.replace(':','- ')}"  "ut_dir=$TORRENT_PATH/$TORRENT_NAME" "ut_kind=multi" "ut_title=$TORRENT_NAME" "ut_label=$TORRENT_LABEL"


Thanks for any help

darkcircuituk
New User
New User
Posts: 3
Joined: Fri Feb 27, 2015 12:29 pm
OS or Distro: Ubuntu

Re: Execute Plugin and Labels

Postby darkcircuituk » Fri Mar 06, 2015 10:30 am

No-one has pulled out labels from deluge in a post processing script?

noze2000
New User
New User
Posts: 1
Joined: Sun Mar 15, 2015 3:21 pm
OS or Distro: MACOS

Re: Execute Plugin and Labels

Postby noze2000 » Sun Mar 15, 2015 3:25 pm

+1 on this.

Sync'ing from my download (seed)box to my local NAS works great.
But I would like to not have a constand xtra opy of my downloads (need to unpack for media center Sickrage/(plex) which means that i need two copies if I am to stop a constant syncing from seedbox to local machine).

This would help a lot

darkcircuituk
New User
New User
Posts: 3
Joined: Fri Feb 27, 2015 12:29 pm
OS or Distro: Ubuntu

Re: Execute Plugin and Labels

Postby darkcircuituk » Mon Mar 23, 2015 10:18 am

I did a bit of digging and found a script in a 2 year old thread that claims it can retrieve the label from a torrent, but I haven't been able to get it working. In the hope that someone can help, or that you have more luck with it than me, here it is:

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()


postprocessingscript:

Code: Select all

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

sndo37
New User
New User
Posts: 9
Joined: Mon Aug 10, 2015 1:34 am
OS or Distro: Windows 10

Re: Execute Plugin and Labels

Postby sndo37 » Tue Aug 11, 2015 1:49 pm

Another +1 on this. Deluge is fantastic, and the plugins are great, but I would LOVE to have to option to copy completed on a per-label basis.

Not sure if anyone is still working on the basic label plugin, but adding a "Copy" option (in addition to the pre-existing "Move" option) would save a ton of headaches for me, and probably others too:)

Weenyhead
New User
New User
Posts: 1
Joined: Fri May 19, 2017 6:14 pm
OS or Distro: Linux

Re: Execute Plugin and Labels

Postby Weenyhead » Fri May 19, 2017 6:26 pm

Little late to this party, but in case someone finds this page like I did, here's the solution I came up with:

Set a different "move to location" (directory) for each label.
Then in your execute script you can check that directory (the path variable).

example:

Code: Select all

#!/bin/bash

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

if [ $torrentpath == "/home/vpn/Downloads/complete/tv" ] ; then
    # do something to tv downloads
elif [ $torrentpath == "/home/vpn/Downloads/complete/movie" ] ; then
    # do something to movie downloads
else
    # do something with all other downloads
fi


Hope that helps :)

PixelBurst
New User
New User
Posts: 1
Joined: Wed May 30, 2018 9:19 am
OS or Distro: Ubuntu 18.04

Re: Execute Plugin and Labels

Postby PixelBurst » Wed May 30, 2018 9:27 am

Weenyhead wrote:Little late to this party, but in case someone finds this page like I did, here's the solution I came up with:

Set a different "move to location" (directory) for each label.
Then in your execute script you can check that directory (the path variable).

example:

Code: Select all

#!/bin/bash

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

if [ $torrentpath == "/home/vpn/Downloads/complete/tv" ] ; then
    # do something to tv downloads
elif [ $torrentpath == "/home/vpn/Downloads/complete/movie" ] ; then
    # do something to movie downloads
else
    # do something with all other downloads
fi


Hope that helps :)


To expand on the late party - I've just set up exactly what OP wants using your post as guidance, so thank you! I thought I'd come and share the finished result to hopefully help others.

So just like Weenyhead said, you can achieve this pretty easily with the example here for an if, elif, else, fi scipt with the downloaded location as the variable, rather than trying to do it on a per label basis. I choose to also package the filebot commands into .sh scripts for ease of use, but you can do it how you like.

Code: Select all

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PATH="/snap/bin:$PATH"
export DISPLAY=:0

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

if [[ $torrentpath == "/media/storage/Downloads/TVToProcess" ]] ; then
     bash /home/pixelburst/bin/tv.sh
     bash /home/pixelburst/bin/cleantv.sh
elif [[ $torrentpath == "/media/storage/Downloads/AnimeToProcess" ]] ; then
     bash /home/pixelburst/bin/anime.sh
     bash /home/pixelburst/bin/cleananime.sh
elif [[ $torrentpath == "/media/storage/Downloads/MoviesToProcess" ]] ; then
     bash /home/pixelburst/bin/movies.sh
     bash /home/pixelburst/bin/cleanmovies.sh
else
    :
fi


So this is the main script, the one you point at from the execute plugin. As you can see I have tv.sh, anime.sh and moviessh downloading into 3 different folders as set up via RSS and watched folders - hence this script looks for them upon a torrent completing to check the path. If it matches TVToProcess/AnimeToProcess/MoviesToProcess it then executes the relevant script. For examples sake, we'll say it matches TVToProcess.
else
:
is very important here as it essentially tells it to do nothing if a completed torrent don't match those folders.

tv.sh looks like this -

Code: Select all

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PATH="/snap/bin:$PATH"
export DISPLAY=:0
filebot -rename "/media/storage/Downloads/TVToProcess" --format "/media/storage/Media/TV Shows/{n}/Season {s.pad(2)}/{n} - {s00e00} - {t}" -non-strict -r --db TheTVDB


this does the filebot renaming - modify the script and format for each desired. Then finally it runs cleantv.sh which looks like so -

Code: Select all

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PATH="/snap/bin:$PATH"
export DISPLAY=:0
filebot -script fn:cleaner --def exts="/jpg|jpeg|png|gif|nfo|xml|htm|html|log|srt|sub|idx|md5|sfv|txt|rtf|url|db|dna|log|tgmd|json|data|srv|srr|nzb|z|aria*|torrent|par\d+|part\d+/" /media/storage/Downloads/TVToProcess


this cleans up any leftovers. Easy!


Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests