2012-07-24 13:44:54 -04:00
|
|
|
// filebot -script fn:artwork.tmdb /path/to/movies/
|
2011-12-27 13:54:25 -05:00
|
|
|
|
|
|
|
/*
|
2011-12-28 09:15:39 -05:00
|
|
|
* Fetch movie artwork. The movie is determined using the parent folders name.
|
2011-12-27 13:54:25 -05:00
|
|
|
*/
|
|
|
|
|
2012-07-28 06:21:30 -04:00
|
|
|
// artwork/nfo helpers
|
2012-07-29 02:09:21 -04:00
|
|
|
include("lib/htpc")
|
2011-12-27 13:54:25 -05:00
|
|
|
|
|
|
|
|
2011-12-28 23:05:10 -05:00
|
|
|
args.eachMediaFolder { dir ->
|
2012-04-01 07:12:33 -04:00
|
|
|
// fetch only missing artwork by default
|
|
|
|
if (_args.conflict == "skip" && dir.hasFile{it =~ /movie.nfo$/} && dir.hasFile{it =~ /folder.jpg$/} && dir.hasFile{it =~ /backdrop.jpg$/}) {
|
|
|
|
println "Skipping $dir"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2011-12-27 13:54:25 -05:00
|
|
|
def videos = dir.listFiles{ it.isVideo() }
|
|
|
|
|
|
|
|
def query = _args.query ?: dir.name
|
2012-01-03 23:09:17 -05:00
|
|
|
def options = TheMovieDB.searchMovie(query, _args.locale)
|
2011-12-27 13:54:25 -05:00
|
|
|
if (options.isEmpty()) {
|
|
|
|
println "Movie not found: $query"
|
2012-04-01 07:12:33 -04:00
|
|
|
return
|
2011-12-27 13:54:25 -05:00
|
|
|
}
|
|
|
|
|
2012-01-03 08:44:31 -05:00
|
|
|
// sort by relevance
|
|
|
|
options = options.sortBySimilarity(query, { it.name })
|
|
|
|
|
2012-07-24 13:44:54 -04:00
|
|
|
// auto-select movie
|
2012-01-03 08:44:31 -05:00
|
|
|
def movie = options[0]
|
|
|
|
|
2012-01-03 23:09:17 -05:00
|
|
|
// maybe require user input
|
|
|
|
if (options.size() != 1 && !_args.nonStrict && !java.awt.GraphicsEnvironment.headless) {
|
|
|
|
movie = javax.swing.JOptionPane.showInputDialog(null, "Please select Movie:", dir.path, 3, null, options.toArray(), movie);
|
2012-01-03 08:44:31 -05:00
|
|
|
if (movie == null) return null
|
|
|
|
}
|
2011-12-27 13:54:25 -05:00
|
|
|
|
2011-12-28 19:51:00 -05:00
|
|
|
println "$dir => $movie"
|
2012-03-23 13:45:50 -04:00
|
|
|
try {
|
2012-12-16 08:26:39 -05:00
|
|
|
fetchMovieArtworkAndNfo(dir, movie, dir.getFiles{ it.isVideo() }.sort{ it.length() }.reverse().findResult{ it }, true)
|
2012-03-23 13:45:50 -04:00
|
|
|
} catch(e) {
|
|
|
|
println "${e.class.simpleName}: ${e.message}"
|
|
|
|
}
|
2011-12-27 13:54:25 -05:00
|
|
|
}
|