Get label in deluge windows for amc

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Divc09
Posts: 7
Joined: 22 Oct 2016, 11:32

Get label in deluge windows for amc

Post by Divc09 »

I have written a script to automate my torrents with the amc and everything is working except one thing. I need a variable to get the label of the torrent to sort it and rename it to the correct format. I don't know the variable to get the label in deluge in cmdline or groovy. OS is windows 7.
My script is

Code: Select all

@echo off
set torrentid=%1
set torrentname=%2
set torrentpath=%3

set torrentname=%torrentname:"=%

filebot -script fn:amc --output "F:/not sorted" --log-file amc.log --action test --conflict override -non-strict --def "ut_label=%L" --def "movieFormat=F:/Div/Movies/{n} ({y})/{n} ({y})" "seriesFormat=F:/Div/Tv/{n.replaceTrailingBrackets()} ({y})/{episode.special ? 'Special' : 'Season '+s+' ('+{episodelist.findAll{ it.season == s }.airdate.year.min()}+')'}/{episode.special ? 'S00E'+special.pad(2) : s00e00} - {t.replacePart(', Part $1')}" "animeFormat=F:/Div/Anime/{n.replaceTrailingBrackets()} ({y})/{episode.special ? 'Special' : 'Season '+s+' ('+{episodelist.findAll{ it.season == s }.airdate.year.min()}+')'}/{episode.special ? 'S00E'+special.pad(2) : s00e00} - {t.replacePart(', Part $1')}" "deleteAfterExtract=y" "subtitles=en" "unsorted=y" "excludeList=amc.txt" "ut_dir=%torrentpath%[b]/[/b]%torrentname%" "ut_kind=multi" "ut_title=%torrentname%" "ut_file=%torrentname%"
The output is

Code: Select all

ipt fn:amc --output "F:/not
override -non-strict --def
y})/{n} ({y})" "seriesForma
ode.special ? 'Special' : '
}.airdate.year.min()}+')'}/
Everything is working perfectlt except for labels. Has anyone managed to do this
There are variables such as torrentname and torrentpath. Does anybody know how the label could work? Please help been stuck at this for days now.
User avatar
rednoah
The Source
Posts: 23931
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get label in deluge windows for amc

Post by rednoah »

Deluge doesn't give you the label, so it's complicated. You can use other 3rd party scripts that will give you the label for a given id.

I'd do something like this: http://forum.deluge-torrent.org/viewtop ... 41#p208649
:idea: Please read the FAQ and How to Request Help.
Divc09
Posts: 7
Joined: 22 Oct 2016, 11:32

Re: Get label in deluge windows for amc

Post by Divc09 »

Well I copied the script there to make a python script and edited my original script to look like this -

Code: Select all

set label=$(C:/Scripts/getLabel.py $torrentid)

set torrentname=%torrentname:"=%

filebot -script fn:amc --output "F:/not sorted" --log-file amc.log --action test --conflict override -non-strict --def "ut_label=%label%" 
I'm not very sure if the syntax is correct and there is'nt really a way to test this so could you tell me if the variable is correct? Thanks a lot for finding the post
User avatar
rednoah
The Source
Posts: 23931
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get label in deluge windows for amc

Post by rednoah »

You're mixing bash and cmd code. That definitely won't work. Blind development without testing every step of the way? That won't work neither, and I see no reason why you wouldn't be able to test every single line by itself.

@see http://stackoverflow.com/questions/2323 ... a-variable
:idea: Please read the FAQ and How to Request Help.
Divc09
Posts: 7
Joined: 22 Oct 2016, 11:32

Re: Get label in deluge windows for amc

Post by Divc09 »

I only know a bit of java so have no idea how to test this. Anyway gonna try and do what i can and update you on the matter
Divc09
Posts: 7
Joined: 22 Oct 2016, 11:32

Re: Get label in deluge windows for amc

Post by Divc09 »

Will this work? This is just cmd code i think

Code: Select all

C:/Scripts/getLabel.py $torrentid > temp.txt
set /p LABEL=<temp.txt
set LABEL=%4
set torrentname=%torrentname:"=%

filebot -script fn:amc --output "F:/not sorted" --log-file amc.log --action test --conflict override -non-strict --def "ut_label=%LABEL%"
In the output it says the the label is%4 which matches with the other variables so I think this might be it. Sorry for asking so much but I've wasted 4 days trying to get this to work with no luck
User avatar
rednoah
The Source
Posts: 23931
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get label in deluge windows for amc

Post by rednoah »

Divc09 wrote:Will this work?
Only Windows CMD can give you an answer for that. I still see a bash $variable so my bet is no. I'd start by making sure your getLabel.py works as expected in the first place.

You could have learn some basic Groovy in less than half a day and avoid CMD completely. On Windows, that's what I'd do.
:idea: Please read the FAQ and How to Request Help.
Divc09
Posts: 7
Joined: 22 Oct 2016, 11:32

Re: Get label in deluge windows for amc

Post by Divc09 »

You could have learn some basic Groovy in half a day and avoid CMD completely
How do I avoid cmd even if i do learn groovy. Don't i have to type the main code out in cmd?
Also the getlabel.py isnt working since it cannot call deluge in the first place. Trying to fix that
User avatar
rednoah
The Source
Posts: 23931
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get label in deluge windows for amc

Post by rednoah »

Depending on how Deluge works, you can either get around CMD completely, or reduce CMD code to 1 line that calls your groovy script and passes along any arguments. In the name of sanity, never use CMD for anything that requires more than 1 line.

In your groovy code you can easily juggle arguments and variables and call 3rd party programs (e.g. python and filebot).

@see https://coderwall.com/p/nswp1q/calling- ... rom-groovy
:idea: Please read the FAQ and How to Request Help.
Divc09
Posts: 7
Joined: 22 Oct 2016, 11:32

Re: Get label in deluge windows for amc

Post by Divc09 »

I have corrected my syntax and everything is working except 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()
The error is
Traceback (most recent call last):
File "C:\Scripts\getLabel.py", line 6, in <module>
from deluge.ui.client import client
ImportError: No module named 'deluge'

I have searched the internet and tried to add the path of the deluge installation to sys.path to no avail.
Could you just tell me how to call deluge.ui.client from a python script. I have no idea how and this the last step that is required. I know that the script is correct because multiple people are using it. Please tell me how to do it. Thanks for all of your help until now.
User avatar
rednoah
The Source
Posts: 23931
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get label in deluge windows for amc

Post by rednoah »

Those imports refer to python libraries: https://docs.python.org/3/installing/

I've never written a single line of python, but I'd try something like this:

Code: Select all

python -m pip install deluge-client
@see https://pypi.python.org/pypi/deluge-client/
:idea: Please read the FAQ and How to Request Help.
Post Reply