AMC --def exec with curl on Windows

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
english06
Posts: 5
Joined: 26 Jan 2019, 07:01

AMC --def exec with curl on Windows

Post by english06 » 26 Jan 2019, 07:09

Running a cmd to send a curl to an 3rd party tool. Script is written as:

Code: Select all

filebot -script fn:amc --action move "***\Complete\Movies" --conflict auto -non-strict --log-file "***\Logs\fb-movies-log.txt" --def pushover=*** --def movieFormat="G:/My Drive/Media/{plex}" --def clean=n --def exec="curl -d \"eventType=Manual&filepath=\mnt\unionfs\Media\{plex}\" http://***:3468/***"
Everything I have read on these forums indicate that the quotes should be escaping properly. However, the script seems to be hanging/breaking on the &. Relevant logs:

Code: Select all

Parameter: exec = curl -d "eventType=Manual
...
Execute: curl -d "eventType=Manual
curl : Invalid URI: The hostname could not be parsed.
At line:1 char:1
+ curl -d eventType=Manual
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], UriFormatException
    + FullyQualifiedErrorId : System.UriFormatException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Done ?(?????)?
'filepath' is not recognized as an internal or external command,
operable program or batch file.
I have checked and if I pull out the command as it should be parsed it works correctly outside of the filebot script. Would greatly appreciate your assistance rednoah.

User avatar
rednoah
The Source
Posts: 15502
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC Exec Errors

Post by rednoah » 26 Jan 2019, 08:57

You're using Windows and PowerShell, so you can't just use Linux / bash / curl commands.

PowerShell aliases Invoke-RestMethod with curl, but it's otherwise completely different from the curl command on Linux you might be familiar with:
https://superuser.com/questions/344927/ ... nt-of-curl

Using curl for Windows might be an easy solution:
https://curl.haxx.se/windows/
:idea: Please read the FAQ and How to Request Help.

english06
Posts: 5
Joined: 26 Jan 2019, 07:01

Re: AMC Exec Errors

Post by english06 » 27 Jan 2019, 00:19

Adding curl.exe does send the correct exec command through. Thanks for that. However the argument is still interrupting at the &. I did also notice that there seems to be spaces inserted around that ampersand when the batch files run.

Saved as:

Code: Select all

--def exec="curl.exe -d \"eventType=Manual&filepath=/mnt/unionfs/Media/{plex}\" http://***:3468/***"
Runs as:

Code: Select all

--def exec="curl.exe -d \"eventType=Manual  & filepath=/mnt/unionfs/Media/{plex}\" http://***3468/***"
Log now shows this at end as expected since the ampersand isn't being read correctly.

Code: Select all

Execute: curl.exe -d "eventType=Manual
curl: no URL specified!
curl: try 'curl --help' for more information
Done ?(?????)?
'filepath' is not recognized as an internal or external command,
operable program or batch file.
Last edited by english06 on 27 Jan 2019, 00:34, edited 1 time in total.

english06
Posts: 5
Joined: 26 Jan 2019, 07:01

Re: AMC Exec Errors

Post by english06 » 27 Jan 2019, 00:26

Changing the inner double quotes to single quotes took care of the ampersand issue. However now the {plex} variable is not working correctly and is being ignored.

Code: Select all

Execute: curl.exe -d 'eventType=Manual&filepath=/mnt/unionfs/Media/' http://***:3468/***
Edit: So after reviewing it seems {plex} and {n} will not pass correctly into the exec. My question then becomes how to specify series name for TV Shows. My movies script works fine since {fn} is the same as the folder name. However, TV shows w/ S00E00 obviously won't work in the same manner.

User avatar
rednoah
The Source
Posts: 15502
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC Exec Errors

Post by rednoah » 27 Jan 2019, 04:23

Strange. It should work:

Code: Select all

Parameter: exec = echo {quote plex}
...
Execute: echo 'TV Shows/Alias/Season 01/Alias - S01E01 - Truth Be Told'
TV Shows/Alias/Season 01/Alias - S01E01 - Truth Be Told
...

If you wanna perform some action on a newly processed file remotely, then using {f} is the only viable parameter, since {plex} is not exactly the output file path. You can do something like this to take the Windows path and translate it to the server-side Unix path:

Code: Select all

/mnt/unionfs{f.path.after(/My.Drive/).replace("\\" , "/")}

:idea: Please run filebot -script fn:sysinfo and post the output.
:idea: Please read the FAQ and How to Request Help.

english06
Posts: 5
Joined: 26 Jan 2019, 07:01

Re: AMC --def exec with curl on Windows

Post by english06 » 28 Jan 2019, 22:42

As requested sys info shows:

Code: Select all

FileBot 4.8.4 (r5829)
JNA Native: 5.2.2
MediaInfo: 18.05
7-Zip-JBinding: 9.20
Chromaprint: 1.4.2
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2019-01-16 (r540)
Groovy: 2.5.1
JRE: Java(TM) SE Runtime Environment 10.0.2
JVM: 64-bit Java HotSpot(TM) 64-Bit Server VM
CPU/MEM: 4 Core / 972 MB Max Memory / 35 MB Used Memory
OS: Windows 10 (amd64)
Package: APPX
License: Microsoft Store License
Done ?(?????)?
As for the script {f} was not pulling any information (similar to previous issue), but changing that to {file} did the trick to pull in the partial path name. However, the "replace" script is erroring the script. Appropriate log lines from failure:

Code: Select all

Parameter: exec = curl.exe -d 'eventType=Manual&filepath=/mnt/unionfs{file.path.after(/TV/).replace(\ , /)}' http://***:3468/***

Code: Select all

SyntaxError: unexpected char: '\'
javax.script.ScriptException: SyntaxError: unexpected char: '\'
        at net.filebot.format.ExpressionFormat.compile(ExpressionFormat.java:85)
        at net.filebot.format.ExpressionFormat.<init>(ExpressionFormat.java:43)
        at net.filebot.cli.ScriptShellBaseClass.getMediaInfo(ScriptShellBaseClass.java:237)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at Script1$_run_closure56.doCall(Script1.groovy:529)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at Script1.run(Script1.groovy:529)
        at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:64)
        at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:74)
        at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:154)
        at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:36)
        at net.filebot.Main.main(Main.java:127)

Failure (°_°)

User avatar
rednoah
The Source
Posts: 15502
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC --def exec with curl on Windows

Post by rednoah » 28 Jan 2019, 23:47

You'll want to check the command that is calling filebot:
viewtopic.php?f=4&t=1899


This part doesn't make sense as far as format code is concerned:

Code: Select all

replace(\ , /)
You'll want it to be this:

Code: Select all

replace("\\" , "/")
:idea: Please read the FAQ and How to Request Help.

english06
Posts: 5
Joined: 26 Jan 2019, 07:01

Re: AMC --def exec with curl on Windows

Post by english06 » 28 Jan 2019, 23:58

It is that in the actual script. I simply copied the output parameter that filebot was providing. Sorry for the confusion

Current script cmd:

Code: Select all

filebot -script fn:amc --action move "G:\***\Complete\TV Shows" --conflict auto -non-strict --log-file "C:\***\Logs\fb-tv-log.txt" --def pushover=*** --def seriesFormat="G:/My Drive/Media/TV/{n}/Season {s}/{n} {s00e00} [{hd}TV-{vf}]" --def clean=n --def exec="curl.exe -d 'eventType=Manual&filepath=/mnt/unionfs{file.path.after(/TV/).replace("\\" , "/")}' http://***:3468/***"

User avatar
rednoah
The Source
Posts: 15502
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC --def exec with curl on Windows

Post by rednoah » 29 Jan 2019, 05:53

A typical mistake. Please read the Escape Arguments section to understand what's going on and how to fix to argument so that you pass the value you want to pass:
viewtopic.php?f=4&t=1899


e.g.

Code: Select all

--def exec="echo '/mnt/unionfs{file.path.after(/TV/).slash(\"/\")}'"

:idea: You may want to consider using the @file syntax for reading command-line arguments from external text files, so you don't have to worry about how PowerShell / Shell argument passing works.
:idea: Please read the FAQ and How to Request Help.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests