filebot

watcher-with-email

Nov 1st, 2013
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.96 KB | None | 0 0
  1. // filebot -script fn:watcher /path/to/folder/ --output /output/folder/ --format <expression>
  2.  
  3. // watch folders and print files that were added/modified
  4. def watchman = args.watch { changes ->
  5.     // extract all
  6.     if (_args.extract)
  7.         changes += extract(file:changes.findAll{ it.isArchive() }, output:'.')
  8.    
  9.     // subtitles for all
  10.     if (_args.getSubtitles)
  11.         changes += getMissingSubtitles(file:changes.findAll{ it.isVideo() }, output:'srt')
  12.    
  13.     // rename all
  14.     if (_args.rename) {
  15.         def renamedFiles = rename(file:changes)
  16.        
  17.         def message = renamedFiles.name.join('\n')
  18.         execute("sendemail.exe", "-f", "sender@mail.com", "-t", "recipient@mail.com", "-s", "smtp.server.com:port", "-u", "Changes", "-m", message)
  19.     }  
  20. }
  21.  
  22. watchman.commitDelay = 5000             // default = 5s
  23. watchman.commitPerFolder = true         // default = true
  24.  
  25. println "Waiting for events"
  26. if (console) { console.readLine() } else { sleep(Long.MAX_VALUE) } // keep running and watch for changes
Add Comment
Please, Sign In to add comment