Combine Watch Script And AMC?
-
- Posts: 10
- Joined: 11 Oct 2013, 14:02
Combine Watch Script And AMC?
I have a remote server set up to automatically push files through SSH to my local machine. Would it be possible to use the watch script to watch the download directory and then run amc on the directory when all downloads are finished? I am very new at this and I having some trouble with it so I appreciate all the help I can get!
Re: Combine Watch Script And AMC?
Here's the example that you can try and see if you get the right events after files have been uploaded:
If that works you can try calling the amc script on the change set:
The internal amc call will inherit all the options you pass when call the script.
Code: Select all
def watchman = args.watch { changes ->
println changes
}
watchman.commitDelay = 5 * 1000 // default = 5s
watchman.commitPerFolder = true // default = true
println "Waiting for events"
if (console) { console.readLine() } else { sleep(Long.MAX_VALUE) } // keep running and watch for changes
If that works you can try calling the amc script on the change set:
Code: Select all
def watchman = args.watch { changes ->
executeScript('fn:amc', _def, changes)
}
watchman.commitDelay = 60 * 1000
watchman.commitPerFolder = true
println "Waiting for events"
if (console) { console.readLine() } else { sleep(Long.MAX_VALUE) } // keep running and watch for changes
-
- Posts: 10
- Joined: 11 Oct 2013, 14:02
Re: Combine Watch Script And AMC?
I am getting this error when trying to run this as a groovy script:
Code: Select all
MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: unexpected char: '\' @ line 1, column 2.
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
^
1 error
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: unexpected char: '\' @ line 1, column 2.
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
^
1 error
at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)
at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (?_?)
Re: Combine Watch Script And AMC?
Looks like you're using the equivalent of MS Word to save your script file...
The groovy script has to be UTF-8 encoded plain-text file. Not some sort of RTF document.
The groovy script has to be UTF-8 encoded plain-text file. Not some sort of RTF document.
Re: Combine Watch Script And AMC?
Played with it and i think a sub-process might work best, but you'll have to specify the args in the script and not in the cmdline:
You may need 3.8 RC for this one to work.
Code: Select all
def watchman = args.watch { changes ->
execute('filebot', '-script', 'fn:amc', '-non-strict', '--output', '/path/to/files', changes)
}
watchman.commitDelay = 60 * 1000
watchman.commitPerFolder = false
println "Waiting for events"
if (console) { console.readLine() } else { sleep(Long.MAX_VALUE) } // keep running and watch for changes
-
- Donor
- Posts: 4
- Joined: 18 Sep 2014, 05:59
Re: Combine Watch Script And AMC?
I'm trying to do something similar to OP, and am unable to get your supplied script (amc within watcher) working. Can you elaborate on how to specify the args in the script?
When I try to call the modified watcher with:
filebot -script "path\to\watcher.groovy" "pathto\stuff" --output "pathto\Export"
I get:
When I try to call the modified watcher with:
filebot -script "path\to\watcher.groovy" "pathto\stuff" --output "pathto\Export"
I get:
MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.def() is applicable for argument types: (net.filebot.cli.ScriptShellMethods$2) values: [net.filebot.cli.ScriptShellMethods$2@e5509d0]
Possible solutions: grep(), get(java.lang.String), grep(java.lang.Object), use([Ljava.lang.Object;), wait(), every()
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.def() is applicable for argument types: (net.filebot.cli.ScriptShellMethods$2) values: [net.filebot.cli.ScriptShellMethods$2@e5509d0]
Possible solutions: grep(), get(java.lang.String), grep(java.lang.Object), use([Ljava.lang.Object;), wait(), every()
at Script1.run(Script1.groovy:1)
at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:60)
at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:81)
at net.filebot.cli.ArgumentProcessor.process(ArgumentProcessor.java:108)
at net.filebot.Main.main(Main.java:191)
Failure (°_°)
-
- Donor
- Posts: 4
- Joined: 18 Sep 2014, 05:59
Re: Combine Watch Script And AMC?
Almost there, the watcher script works great when files are placed in the input folder. However, it does not trigger when folders are put in the input directory. How can I have the script do both?
Appreciate the support, thank you!
Appreciate the support, thank you!
Re: Combine Watch Script And AMC?
This should work:
See method definitions:
See net/filebot/cli/ScriptShellMethods.java for details.
But if you need to watch the entire tree you're probably doing something wrong already in your setup. I don't recommend watching more than one specific folder.
Code: Select all
f.watchFolder(true, true, 5000)
Code: Select all
FolderWatchService watchFolder(File self, Closure<?> callback)
FolderWatchService watchFolder(File self, boolean watchTree, boolean commitPerFolder, long commitDelay, final Closure<?> callback)
But if you need to watch the entire tree you're probably doing something wrong already in your setup. I don't recommend watching more than one specific folder.
-
- Donor
- Posts: 4
- Joined: 18 Sep 2014, 05:59
Re: Combine Watch Script And AMC?
Yea it's not ideal, however I wanted to have a monitored folder where others could 'dump' their media files/folders into and then have filebot process/sort it into the correct folder structure that the rest of my own downloads/files already follow.
Edit: If I'm reading correctly, do you mean:
def output = '/Users/reinhard/Downloads/output/'
def input = '/Users/reinhard/Downloads/complete/'
(input as File).watchFolder(true, true, 5000) { files ->
executeScript('dev:amc', ['--action', 'duplicate', '-non-strict', '--output', output], [minFileSize:0], files)
}
sleep Integer.MAX_VALUE
Edit: If I'm reading correctly, do you mean:
def output = '/Users/reinhard/Downloads/output/'
def input = '/Users/reinhard/Downloads/complete/'
(input as File).watchFolder(true, true, 5000) { files ->
executeScript('dev:amc', ['--action', 'duplicate', '-non-strict', '--output', output], [minFileSize:0], files)
}
sleep Integer.MAX_VALUE