* support all -rename -get-subtitles -extract functionality out of the box in housekeeping and watcher scripts
This commit is contained in:
parent
f9d2e9dbf8
commit
6b6839579e
|
@ -138,8 +138,8 @@ def createWatchService(Closure callback, List folders, boolean watchTree) {
|
|||
}
|
||||
}
|
||||
|
||||
// collect updates for 5 minutes and then batch process
|
||||
watchService.setCommitDelay(5 * 60 * 1000)
|
||||
// collect updates for 500 ms and then batch process
|
||||
watchService.setCommitDelay(500)
|
||||
watchService.setCommitPerFolder(watchTree)
|
||||
|
||||
// start watching given files
|
||||
|
@ -275,13 +275,15 @@ def _files(args) {
|
|||
(args.folder as File).traverse(type:FILES, maxDepth:0) { files += it }
|
||||
}
|
||||
if (args.file) {
|
||||
if (args.file instanceof Iterable || args.file instanceof File[]) {
|
||||
if (args.file instanceof Iterable || args.file instanceof Object[]) {
|
||||
files += args.file as List
|
||||
} else {
|
||||
files += args.file as File
|
||||
}
|
||||
}
|
||||
return files
|
||||
|
||||
// ignore invalid input
|
||||
return files.flatten().findResults{ it as File }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,21 @@ def updateFrequency = 5 * 60 * 1000
|
|||
// spawn daemon thread
|
||||
Thread.startDaemon {
|
||||
while (sleep(updateFrequency) || true) {
|
||||
args.eachMediaFolder {
|
||||
rename(folder:it)
|
||||
// extract all
|
||||
if (_args.extract) {
|
||||
extract(file:args.getFiles{ it.isArchive() }, output:'.')
|
||||
}
|
||||
|
||||
// subtitles for all
|
||||
if (_args.getSubtitles) {
|
||||
getMissingSubtitles(file:args.getFiles{ it.isVideo() }, output:'srt')
|
||||
}
|
||||
|
||||
// rename all
|
||||
if (_args.rename) {
|
||||
args.eachMediaFolder {
|
||||
rename(folder:it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
// filebot -script fn:watcher /path/to/folder/ --output /output/folder/ --format <expression>
|
||||
|
||||
// watch folders and print files that were added/modified
|
||||
args.watch { changes ->
|
||||
rename(file:changes)
|
||||
def watchman = args.watch { changes ->
|
||||
// extract all
|
||||
if (_args.extract)
|
||||
changes += extract(file:changes.findAll{ it.isArchive() }, output:'.')
|
||||
|
||||
// subtitles for all
|
||||
if (_args.getSubtitles)
|
||||
changes += getMissingSubtitles(file:changes.findAll{ it.isVideo() }, output:'srt')
|
||||
|
||||
// rename all
|
||||
if (_args.rename)
|
||||
rename(file:changes)
|
||||
}
|
||||
|
||||
watchman.commitDelay = 5 * 1000 // default = 5s
|
||||
watchman.commitPerFolder = true // default = true
|
||||
|
||||
println "Waiting for events"
|
||||
console.readLine() // keep running and watch for changes
|
||||
|
|
Loading…
Reference in New Issue