mirror of
https://github.com/mitb-archive/filebot
synced 2024-08-13 17:03:45 -04:00
* make watcher/housekeeping more general
This commit is contained in:
parent
47cd4a8a2d
commit
1335105a58
@ -205,7 +205,7 @@ List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> o
|
|||||||
// call scripts
|
// call scripts
|
||||||
def include(String input, Map parameters = [:], Object... args) {
|
def include(String input, Map parameters = [:], Object... args) {
|
||||||
// initialize default parameter
|
// initialize default parameter
|
||||||
parameters.args = (args as List).findResults{ it as File }
|
parameters.args = (args as List).flatten().findResults{ it as File }
|
||||||
|
|
||||||
// run given script and catch exceptions
|
// run given script and catch exceptions
|
||||||
_guarded { _shell.runScript(input, new javax.script.SimpleBindings(parameters)) }
|
_guarded { _shell.runScript(input, new javax.script.SimpleBindings(parameters)) }
|
||||||
|
@ -1,21 +1,17 @@
|
|||||||
// filebot -script "http://filebot.sf.net/scripts/housekeeping.groovy" <folder>
|
// filebot -script fn:housekeeping /path/to/folder/ --output /output/folder/ --format <expression>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Watch folder for new tv shows and automatically
|
* Watch folder for new tv shows and automatically move/rename new episodes
|
||||||
* move/rename new episodes into a predefined folder structure
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// check for new media files once every 5 minutes
|
// check for new media files once every 5 minutes
|
||||||
def updateFrequency = 5 * 60 * 1000
|
def updateFrequency = 5 * 60 * 1000
|
||||||
|
|
||||||
// V:/TV Shows/Stargate/Season 1/Stargate.S01E01.Pilot
|
|
||||||
def episodeFormat = "{com.sun.jna.Platform.isWindows() ? file[0] : home}/TV Shows/{n}{'/Season '+s}/{n.space('.')}.{s00e00}.{t.space('.')}"
|
|
||||||
|
|
||||||
// spawn daemon thread
|
// spawn daemon thread
|
||||||
Thread.startDaemon {
|
Thread.startDaemon {
|
||||||
while (sleep(updateFrequency) || true) {
|
while (sleep(updateFrequency) || true) {
|
||||||
args.eachMediaFolder {
|
args.eachMediaFolder {
|
||||||
rename(folder:it, db: "thetvdb", format:episodeFormat)
|
rename(folder:it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,9 @@
|
|||||||
// filebot -script "http://filebot.sf.net/scripts/watcher.groovy" --format <expression> <folder>
|
// filebot -script fn:watcher /path/to/folder/ --output /output/folder/ --format <expression>
|
||||||
|
|
||||||
// SANITY CHECK
|
// watch folders and print files that were added/modified
|
||||||
if (_prop['java.runtime.version'] < '1.7') throw new Exception('Java 7 required')
|
args.watch { changes ->
|
||||||
if (!(new File(_args.format ?: '').absolute)) throw new Exception('Absolute target path format required')
|
|
||||||
|
|
||||||
|
|
||||||
// watch folders and print files that were added/modified (requires Java 7)
|
|
||||||
def watchman = args.watch { changes ->
|
|
||||||
println "Processing $changes"
|
|
||||||
rename(file:changes)
|
rename(file:changes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// process after 5 minutes without any changes to the folder
|
|
||||||
watchman.setCommitDelay(5 * 60 * 1000)
|
|
||||||
|
|
||||||
println "Waiting for events"
|
println "Waiting for events"
|
||||||
console.readLine() // keep running and watch for changes
|
console.readLine() // keep running and watch for changes
|
||||||
|
Loading…
Reference in New Issue
Block a user