* added special handling for disk folders

This commit is contained in:
Reinhard Pointner 2012-10-30 09:48:34 +00:00
parent 4063f57e54
commit 0840791140
2 changed files with 17 additions and 6 deletions

View File

@ -194,8 +194,8 @@ def isEpisode(path, strict = true) {
return MediaDetection.isEpisode(input, strict) return MediaDetection.isEpisode(input, strict)
} }
def guessMovieFolder(path) { def guessMovieFolder(File path) {
return MediaDetection.guessMovieFolder(path as File) return MediaDetection.guessMovieFolder(path)
} }
def parseEpisodeNumber(path, strict = true) { def parseEpisodeNumber(path, strict = true) {
@ -214,7 +214,7 @@ def detectSeriesName(files, locale = Locale.ENGLISH) {
return names == null || names.isEmpty() ? null : names.toList()[0] return names == null || names.isEmpty() ? null : names.toList()[0]
} }
def detectMovie(movieFile, strict = true, queryLookupService = TheMovieDB, hashLookupService = OpenSubtitles, locale = Locale.ENGLISH) { def detectMovie(File movieFile, strict = true, queryLookupService = TheMovieDB, hashLookupService = OpenSubtitles, locale = Locale.ENGLISH) {
def movies = MediaDetection.detectMovie(movieFile, hashLookupService, queryLookupService, locale, strict) def movies = MediaDetection.detectMovie(movieFile, hashLookupService, queryLookupService, locale, strict)
return movies == null || movies.isEmpty() ? null : movies.toList()[0] return movies == null || movies.isEmpty() ? null : movies.toList()[0]
} }

View File

@ -44,20 +44,31 @@ def forceIgnore(f) {
} }
// specify how to resolve input folders, e.g. grab files from all folders except disk folders
def resolveInput(f) {
if (f.isDirectory() && !f.isDisk())
return f.listFiles().toList().findResults{ resolveInput(it) }
else
return f
}
// collect input fileset as specified by the given --def parameters // collect input fileset as specified by the given --def parameters
if (args.empty) { if (args.empty) {
// assume we're called with utorrent parameters // assume we're called with utorrent parameters
if (ut_kind == 'single') { if (ut_kind == 'single') {
input += new File(ut_dir, ut_file) // single-file torrent input += new File(ut_dir, ut_file) // single-file torrent
} else { } else {
input += new File(ut_dir).getFiles() // multi-file torrent input += resolveInput(ut_dir as File) // multi-file torrent
} }
} else { } else {
// assume we're called normally with arguments // assume we're called normally with arguments
input += args.getFiles() input += args.findResults{ resolveInput(it) }
} }
// flatten nested file structure
input = input.flatten()
// extract archives (zip, rar, etc) that contain at least one video file // extract archives (zip, rar, etc) that contain at least one video file
input += extract(file: input.findAll{ it.isArchive() }, output: null, conflict: 'override', filter: { it.isVideo() }, forceExtractAll: true) input += extract(file: input.findAll{ it.isArchive() }, output: null, conflict: 'override', filter: { it.isVideo() }, forceExtractAll: true)
@ -65,7 +76,7 @@ input += extract(file: input.findAll{ it.isArchive() }, output: null, conflict:
input = input.findAll{ it?.exists() }.collect{ it.canonicalFile }.unique() input = input.findAll{ it?.exists() }.collect{ it.canonicalFile }.unique()
// process only media files // process only media files
input = input.findAll{ it.isVideo() || it.isSubtitle() } input = input.findAll{ it.isVideo() || it.isSubtitle() || it.isDisk() }
// ignore clutter files // ignore clutter files
input = input.findAll{ !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook)\b/) } input = input.findAll{ !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook)\b/) }