Page 1 of 1
[Windows][NZBGet][Script] Need help with Post Process Script
Posted: 07 Feb 2016, 02:10
by Zer0Cool
Setup
OS: Windows Server 2012 R2 Essentials
Filebot: 4.6.1
Downloaders: NZBGet and uTorrent
I've got things setup so that uTorrent runs a script that renames files and according to them being either movies or TV shows moves them to the proper folder/structure. That works 100% no issues and is based on the directions found
viewtopic.php?f=4&t=215. My issue is that this does NOT work at all for post processing when called from NZBGet with the code placed in a .bat file.
Current Script
In uTorrent in the Run program field i have the following:
Code: Select all
"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/ServerFolders/Downloads/Check" --log-file amc.log --action move --conflict override -non-strict --def subtitles=en "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D" "seriesFormat=D:/ServerFolders/TV Shows/{n}/{n} Season {s}/{n} - {s00e00} - {t}" "movieFormat=D:/ServerFolders/Movies/HD/{n} ({y})" clean=y deleteAfterExtract=y excludeList=amc-input.txt
The .bat that NZBGet calls:
Code: Select all
@echo off
goto start:
########################################
### NZBGET POST-PROCESSING SCRIPT ###
# Brief description goes here.
#
# Lengthier description and instructions go here. Blah, blah blah
# and so on and so forth....
########################################
### OPTIONS ###
# An option goes here, do you want that? (yes, no).
#
# The explanation of the option goes here...
#DoYouWantThisOption=no
### NZBGET POST-PROCESSING SCRIPT ###
#########################################
:start
"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/ServerFolders/Downloads/Check" --log-file amc.log --action move --conflict override -non-strict --def subtitles=en "seriesFormat=D:/ServerFolders/TV Shows/{n}/{n} Season {s}/{n} - {s00e00} - {t}" "movieFormat=D:/ServerFolders/Movies/HD/{n} ({y})" clean=y deleteAfterExtract=y excludeList=amc-input.txt
rem Return an exit code understood by nzbget
rem # Exit codes used by NZBGet
rem POSTPROCESS_SUCCESS=93
rem POSTPROCESS_NONE=95
rem POSTPROCESS_ERROR=94
exit /b 93
When the .bat is called it logs an error as follows:
Code: Select all
Run script [fn:amc] at [Sat Feb 06 20:40:11 EST 2016]
Parameter: subtitles = en
Parameter: seriesFormat = D:/ServerFolders/TV Shows/{n}/{n} Season {s}/{n} - {s00e00} - {t}
Parameter: movieFormat = D:/ServerFolders/Movies/HD/{n} ({y})
Parameter: clean = y
Parameter: deleteAfterExtract = y
Parameter: excludeList = amc-input.txt
Invalid arguments: pass in either file arguments or ut_dir/ut_file parameters but not both
Failure (°_°)
Originally i thought this was due to having the .bat script include the various ut_* stuff from the uTorrent run command, so i removed them all. So the file completes, but stays in my completed downloads folder and is never renamed or moved by Filebot.
My requirements are essentially:
- - Identify if the file is a movie or a TV show
- - Move it to the desired folder/structure based on if its a movie or TV show
- - Cleanup after rename move
- - While not required, grab the subtitles from Opensubs
So im asking for help either modifying what i have or rewriting a script that will accomplish this. For what its worth i asked for help in the nzbget forums and didnt get much help. Thank you
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 07 Feb 2016, 05:31
by rednoah
You're not passing in any input files.
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 07 Feb 2016, 08:01
by Zer0Cool
rednoah wrote:You're not passing in any input files.
Ok how do I get it to do that then?
Like i said, i got this working for uTorrent based off the post here, but i cannot find any information anywhere about how to get filebot to work with NZBGet. I tried to alter this and put it in a bat file for NZBGet to run, but i obviously need someones help who understands the scripting more than I do. I assumed because it understood when run from uTorrent which file I meant that itd work when run from NZBGet
Thanks
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 07 Feb 2016, 09:19
by rednoah
1.
This is your command:
Code: Select all
"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/ServerFolders/Downloads/Check" --log-file amc.log --action move --conflict override -non-strict --def subtitles=en "seriesFormat=D:/ServerFolders/TV Shows/{n}/{n} Season {s}/{n} - {s00e00} - {t}" "movieFormat=D:/ServerFolders/Movies/HD/{n} ({y})" clean=y deleteAfterExtract=y excludeList=amc-input.txt
Question: How does the amc script know which files/folders it should be processing?
2.
The "command" that works in uTorrent is not a command, it's a template for a command. If you want to use the same command from outside of uTorrent, then you have to replace the
%variables yourself with the expected values somehow. Read the
Troubleshooting section.
NZBGet: Executes bat script (possibly passing arguments or environment variables)
uTorrent: Replaces all the variables in your command template, and then executes the resulting command
The first thing you need to figure out is how NZBGet passes files/labels/etc and if processing newly finished files for some reason you can just set it to process everything every time (make sure you correctly set --def excludeList though).
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 08 Feb 2016, 04:03
by Zer0Cool
OK so if i follow along correctly, this part in the utorrent script is what tells Filebot which file from uTorrent to process:
Code: Select all
"ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"
So i need to find a similar way to handle the NZBGet post process script by either referencing the files specifically (via a variable/label of some sort)?
As a side note, has no one ever asked about using Filebot to post process for NZBGet, i cant find any mention of the 2 together on the web.
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 08 Feb 2016, 04:31
by Zer0Cool
Alright, so I did some reading in the NZBGet documentation for scripting. This link points to a way to declare variables, including the name/path of the file being processed (or finished).
https://github.com/nzbget/nzbget/wiki/P ... ng-scripts
So for example something like:
- - NZBPP_NZBFILENAME | this is a full file name, including path and extension. (should be anyway)
So am I able to use that variable within the Filebot command or do i have to pass the value of that variable into something that Filebot will understand?
For ex (excerpt of my original code/bat script. Variable added after subtitles=en):
Code: Select all
:start
"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/ServerFolders/Downloads/Check" --log-file amc.log --action move --conflict override -non-strict --def subtitles=en NZBPP_NZBFILENAME "seriesFormat=D:/ServerFolders/TV Shows/{n}/{n} Season {s}/{n} - {s00e00} - {t}" "movieFormat=D:/ServerFolders/Movies/HD/{n} ({y})" clean=y deleteAfterExtract=y excludeList=amc-input.txt
I will test the above to see what happens. Thanks again!
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 08 Feb 2016, 05:31
by Zer0Cool
Ok didnt work as i had it above. Looks like i cant just stick the variable in there.
So after reading over the documentation for Filebot I dont understand what the syntax is to pass it an input file/source. For example, what would i do in my script if i wanted to statically name a file as the source?
Additionally i just noticed that both programs I use to download should assign movies a category and TV shows another category when passed to NZBGet, not sure if this would be helpful or just a similar issue to what i already have (how to pass the categories from NZBGet to Filebot)?
Thanks
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 08 Feb 2016, 08:31
by rednoah
1.
The
Troubleshooting section shows a filebot command as executed by uTorrent:
Code: Select all
filebot -script fn:amc --output "D:/Organized Media" --log-file amc.log --action duplicate --conflict override -non-strict --def "ut_dir=D:\Media\Avatar" "ut_file=" "ut_kind=multi" "ut_title=Avatar" "ut_label=" "ut_state=5"
Look!
--def "ut_dir=%F" magically became
--def "ut_dir=D:\Media\Avatar"
The
Run from cmdline section shows how you can pass in input paths like with any other command-line tool:
Code: Select all
filebot -script fn:amc --output "/path/to/output" --action copy -non-strict "/path/to/input" --log-file amc.log --def excludeList=amc.txt
Where
/path/to/input means "path to the files/folders that you want to process".
2.
It looks like you have no idea
How to use variables in Windows CMD scripts.
Time to level up! Read this:
http://steve-jansen.github.io/guides/wi ... ables.html
3.
Your cmd script would probably like a little bit like this:
Code: Select all
SET INPUT=…
SET LABEL=…
…
filebot … --def "ut_dir=%INPUT%" "ut_kind=multi" "ut_label=%LABEL%"
4.
If you don't know what you're doing,
DO NOT USE filebot.launcher.exe, because that will hide console output and prevent you from ever finding out what you're doing.

Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 08 Feb 2016, 10:18
by rednoah
1.
Did you check if nzbget supports postprocessing scripts on Windows? All the examples are for Linux.
EDIT:
On Linux it would probably look like this:
https://github.com/filebot/plugins/blob ... process.sh
2.
What's the output of filebot -script fn:sysenv when called by nzbget as post processing script?
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 08 Feb 2016, 23:38
by Zer0Cool
rednoah wrote:1.
Look!
--def "ut_dir=%F" magically became
--def "ut_dir=D:\Media\Avatar"
Code: Select all
filebot -script fn:amc --output "/path/to/output" --action copy -non-strict "/path/to/input" --log-file amc.log --def excludeList=amc.txt
Where
/path/to/input means "path to the files/folders that you want to process".
3.
Your cmd script would probably like a little bit like this:
Code: Select all
SET INPUT=…
SET LABEL=…
…
filebot … --def "ut_dir=%INPUT%" "ut_kind=multi" "ut_label=%LABEL%"
Yes NZBGet does support bat files in Windows, i had checked because originally i was hoping for a run program thing like uTorrent has.
See i found that confusing. In one case the syntax is '--def "ut_dir=*"' and in another its just a path without '--def'. Thanks for the examples, I honestly didnt see them while reviewing the documentation, but this is all a lot to absorb.
So in #3 you are saying i would assign the NZBGet variable for the path to the CMD variable "Input" and then reference the CMD variable in my bat file/Filebot line using the "--def "ut_dir=" parameter?
I will experiment with it and get back with results. Thanks again
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 09 Feb 2016, 00:13
by Zer0Cool
Looks like when i use this:
Code: Select all
:start
SET INPUT=NZBPP_DIRECTORY
"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/ServerFolders/Downloads/Check" --log-file amc.log --action move --conflict override -non-strict --def subtitles=en "ut_dir=%INPUT%" "seriesFormat=D:/ServerFolders/TV Shows/{n}/{n} Season {s}/{n} - {s00e00} - {t}" "movieFormat=D:/ServerFolders/Movies/HD/{n} ({y})" clean=y deleteAfterExtract=y excludeList=amc-input.txt
Its passing %Input% as a string "NZBPP_DIRECTORY" and not the value of the env variable that NZBPP_DIRECTORY should represent. NZBPP_DIRECTORY seems to be the variable i should be using as this passes the directory that the finished download goes to (as per response to my post on NZBGet formums).
Also are "ut_kind" and "ut_label" required parameters?
Thanks
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 09 Feb 2016, 00:22
by rednoah
1.
Run this as post processing script:
Code: Select all
"C:/Program Files/FileBot/filebot.exe" -script fn:sysenv --log-file "D:/sysenv.txt"
Then paste the contents of
D:/sysenv.txt here in the forums.
2.
Try this:
Code: Select all
"C:/Program Files/FileBot/filebot.exe" -script fn:amc --output "D:/Media" --action copy --conflict skip -non-strict --log-file amc.log --def excludeList=amc.excludes "ut_dir=%NZBPP_DIRECTORY%" "ut_kind=multi" "ut_title=%NZBPP_NZBNAME%" "ut_label=%NZBPP_CATEGORY%"
Don't add lots of options you don't yet understand until you get it working with the defaults.
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 16 Feb 2016, 07:15
by Zer0Cool
Thanks. Sorry I just got the chance to try some stuff and got it working.
This is my working code. Run when NZBGet finishes a download as a post process script from a .bat file:
Code: Select all
@echo off
goto start:
########################################
### NZBGET POST-PROCESSING SCRIPT ###
# Brief description goes here.
#
# Lengthier description and instructions go here. Blah, blah blah
# and so on and so forth....
########################################
### OPTIONS ###
# An option goes here, do you want that? (yes, no).
#
# The explanation of the option goes here...
#DoYouWantThisOption=no
### NZBGET POST-PROCESSING SCRIPT ###
#########################################
:start
"C:/Program Files/FileBot/filebot.launcher.exe" -script fn:amc --output "D:/ServerFolders/Downloads/Check" --log-file amc.log --action move --conflict override -non-strict --def subtitles=en "ut_label=%NZBPP_CATEGORY%" "ut_title=%NZBPP_NZBNAME%" "ut_kind=multi" "ut_dir=%NZBPP_DIRECTORY%" "seriesFormat=D:/ServerFolders/TV Shows/{n}/{n} Season {s}/{n} - {s00e00} - {t}" "movieFormat=D:/ServerFolders/Movies/HD/{n} ({y})" clean=y deleteAfterExtract=y excludeList=amc-input.txt
rem Return an exit code understood by nzbget
rem # Exit codes used by NZBGet
rem POSTPROCESS_SUCCESS=93
rem POSTPROCESS_NONE=95
rem POSTPROCESS_ERROR=94
exit /b 93
There is likely some stuff I could remove from this or expand on (like the options section) but for now its doing exactly what i need. Thanks again.
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 16 Feb 2016, 07:39
by Zer0Cool
I guess one last question. Is:
all i need to have it get missing subtitles?
Essentially the only thing id like to do in addition to what im doing now is get english subs, but only if it wasnt included with the download. I have my doubts that the above is doing this. Any help would be great as ive poked around and havent found anything that I am wrapping my head around right now, then again im up way too late. Thanks
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 16 Feb 2016, 07:53
by rednoah
The above is doing that.
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 17 Feb 2016, 06:09
by Zer0Cool
rednoah wrote:The above is doing that.
Thank you. Is there an advantage to creating an opensubs account, and if so how would I add that into my parameters?
I think my last question is regarding Sonarr and Filebot, specifically if I can have Sonarr be notified that the file is done and moved/processed. The post
here seems to indicate this is possible with some custom version of amc. That post however is a bit over a year old and seemed to include other features that are now part part of Filebot (as far as I can tell) like plex updating. Any chance this is now a built in part of Filebot?
Otherwise, again, thank you very much!
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 17 Feb 2016, 08:18
by rednoah
Setting up an OpenSubtitles account is required. If you don't, it won't work and the logs will contain warning messages.
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 17 Feb 2016, 15:18
by Zer0Cool
rednoah wrote:Setting up an OpenSubtitles account is required. If you don't, it won't work and the logs will contain warning messages.
Thank you ill setup an account then. What would the syntax be to add that to my parameters?
Right now i have:
I presume id have to add my account info somehow, or do I just do that in the Filebot GUI? If I have to add it to the parameter what would the syntax be? Ill of course read through the documentation I can find, but in a brief search didnt find anything that stood out. Thanks
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 17 Feb 2016, 15:39
by Zer0Cool
Ok I think I may have found my answer.
So the steps would be something like:
1) go create an account
2) run this command
2a) the command should prompt me to enter my account/pw
3) my code with:
should then work?
Thanks
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 17 Feb 2016, 20:30
by Zer0Cool
Another silly question. Couldnt find the answer to this. I have the parameter for cleaning:
Is there any way to have Filebot also delete unwanted subtitles (srts) that where downloaded for a episode or movie. For example, if I download "Best Movie Ever", and it includes subs in english, spanish, and french. If I only want english subs can file bot as part of my post processing script trash the spanish/french subs?
Once this script is running smooth (99% there) ill create a post with an explanation and directions in your forums if you like, to help others with a similar setup. Thanks again!
Re: [Windows][NZBGet][Script] Need help with Post Process Sc
Posted: 18 Feb 2016, 07:20
by rednoah
Have you tried the latest revision of the script by calling dev:amc instead?
The clean option should delete subs if action copy/duplicate is used.