SHOW:
|
|
- or go back to the newest paste.
| 1 | - | // filebot -script "fn:utorrent-postprocess" --output "X:/media" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=%D" "-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K" |
| 1 | + | |
| 2 | def failOnError = _args.conflict == 'fail' | |
| 3 | ||
| 4 | // print input parameters | |
| 5 | _args.parameters.each{ k, v -> println "Parameter: $k = $v" }
| |
| 6 | ||
| 7 | if (args.empty) {
| |
| 8 | - | if (args.empty) {a
|
| 8 | + | |
| 9 | if (ut_kind == "multi") {
| |
| 10 | input += new File(ut_dir).getFiles() // multi-file torrent | |
| 11 | } else {
| |
| 12 | input += new File(ut_dir, ut_file) // single-file torrent | |
| 13 | } | |
| 14 | } else {
| |
| 15 | // assume we're called normally with arguments | |
| 16 | input += args.getFiles() | |
| 17 | } | |
| 18 | ||
| 19 | // extract archives if necessary | |
| 20 | input += extract(file:input, output:".", conflict:"override") | |
| 21 | ||
| 22 | // process only media files | |
| 23 | input = input.findAll{ it.isVideo() || it.isSubtitle() }
| |
| 24 | ||
| 25 | // ignore clutter files | |
| 26 | input = input.findAll{ !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook)\b/) }
| |
| 27 | ||
| 28 | // print input fileset | |
| 29 | input.each{ println "Input: $it" }
| |
| 30 | ||
| 31 | // group episodes/movies and rename according to XBMC standards | |
| 32 | def groups = input.groupBy{ f ->
| |
| 33 | def tvs = detectSeriesName(f) | |
| 34 | def mov = (parseEpisodeNumber(f) || parseDate(f)) ? null : detectMovie(f, false) // skip movie detection if we can already tell it's an episode | |
| 35 | println "$f.name [series: $tvs, movie: $mov]" | |
| 36 | ||
| 37 | // DECIDE EPISODE VS MOVIE (IF NOT CLEAR) | |
| 38 | if (tvs && mov) {
| |
| 39 | def fn = f.nameWithoutExtension.space(' ')
| |
| 40 | if (fn =~ "(?i:$tvs - .+)" || parseEpisodeNumber(fn, true) || parseDate(fn)) {
| |
| 41 | println "Exclude Movie: $mov" | |
| 42 | mov = null | |
| 43 | } else if (detectMovie(f, true) && (fn =~ /(19|20)\d{2}/ || !(tvs =~ "(?i:$mov.name)"))) {
| |
| 44 | println "Exclude Series: $tvs" | |
| 45 | tvs = null | |
| 46 | } else if (fn =~ "(?i:$tvs)" && parseEpisodeNumber(fn.after(tvs), false)) {
| |
| 47 | println "Exclude Movie: $mov" | |
| 48 | mov = null | |
| 49 | } else if (fn =~ "(?i:$mov.name)" && !parseEpisodeNumber(fn.after(mov.name), false)) {
| |
| 50 | println "Exclude Series: $tvs" | |
| 51 | tvs = null | |
| 52 | } | |
| 53 | } | |
| 54 | ||
| 55 | // CHECK CONFLICT | |
| 56 | if (((mov && tvs) || (!mov && !tvs)) && failOnError) {
| |
| 57 | throw new Exception("Media detection failed")
| |
| 58 | } | |
| 59 | ||
| 60 | return [tvs:tvs, mov:mov] | |
| 61 | } | |
| 62 | ||
| 63 | groups.each{ group, files ->
| |
| 64 | // fetch subtitles | |
| 65 | files += (getMissingSubtitles(file:files, lang:"he") ?: []) | |
| 66 | files += (getMissingSubtitles(file:files, lang:"en") ?: []) | |
| 67 | ||
| 68 | // EPISODE MODE | |
| 69 | if (group.tvs && !group.mov) {
| |
| 70 | - | if (dest || failOnError) {
|
| 70 | + | |
| 71 | - | dest.mapByFolder().each{ dir, fs ->
|
| 71 | + | |
| 72 | - | } |
| 72 | + | |
| 73 | - | options = options.sortBySimilarity(query, { it.name })
|
| 73 | + | |
| 74 | - | |
| 74 | + | |
| 75 | - | } |
| 75 | + | |
| 76 | } | |
| 77 | } |