Page 1 of 1

Filenotfound exception when fetching movie info

Posted: 23 Mar 2012, 08:48
by Raphy

I'm using the command-line for fetching movie info, with the script "artwork.tmdb.db":

Code: Select all

filebot -script [...]/filebot/artwork.tmdb.groovy -trust-script -non-strict Films
It does find some movies, but quickly run into this error:

Code: Select all

/home/raphy/Films/./2012 => 2012 (2011)
Fetch nfo and artwork for 2012 (2011)
at net.sourceforge.filebot.web.WebRequest.getReader(Unknown Source)
at net.sourceforge.filebot.web.CachedPage.openConnection(Unknown Source)
at net.sourceforge.filebot.web.CachedPage.fetchData(Unknown Source)
at net.sourceforge.filebot.web.CachedResource.get(Unknown Source)
at net.sourceforge.filebot.web.TMDbClient.fetchResource(Unknown Source)
at net.sourceforge.filebot.web.TMDbClient.getMovieInfoByIMDbID(Unknown Source)
at net.sourceforge.filebot.web.TMDbClient.getMovieInfo(Unknown Source)
at Source)
at Script3.fetchMovieArtworkAndNfo(Script3.groovy:39)
at Script3.doCall(Script3.groovy:81)
at Script2.doCall(Script2.groovy:27)
at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at Source)
at Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)
at net.sourceforge.filebot.Main.main(Unknown Source)
I tried top get the xml file mentionned ( ... 45be99f13/) and there is a not found error. But how can filebot get around it and move on instead of exiting?

Thank you

Re: Filenotfound exception when fetching movie info

Posted: 23 Mar 2012, 08:58
by rednoah
Oh? Looks like that happens when the API has no data for the given movie?

Just put that part into an an try {} catch {} block and it should catch those errors.

Re: Filenotfound exception when fetching movie info

Posted: 23 Mar 2012, 09:51
by Raphy
Seems to do the trick.

Thank you very much!

Here's is my modified script:

Code: Select all

// filebot -script "" -trust-script /path/to/media/

 * Fetch movie artwork. The movie is determined using the parent folders name.

def fetchArtwork(outputFile, movieInfo, artworkType, artworkSize) {
	// select and fetch artwork
	def artwork = movieInfo.images.find { it.type == artworkType && it.size == artworkSize }
	if (artwork == null) {
		println "Artwork not found: $outputFile"
		return null
	println "Fetching $outputFile => $artwork"
	return artwork.url.saveAs(outputFile)

def fetchNfo(outputFile, movieInfo) {
			<genre>${!genres.empty ? genres[0] : ''}</genre>

def fetchMovieArtworkAndNfo(movieDir, movie) {
	println "Fetch nfo and artwork for $movie"
	try {
		def movieInfo = TheMovieDB.getMovieInfo(movie, Locale.ENGLISH)
		println movieInfo
		movieInfo.images.each {
			println "Available artwork: $it.url => $it"
		// fetch nfo
		fetchNfo(movieDir['movie.nfo'], movieInfo)
		// fetch series banner, fanart, posters, etc
		fetchArtwork(movieDir['folder.jpg'], movieInfo, 'poster', 'original')
		fetchArtwork(movieDir['backdrop.jpg'], movieInfo, 'backdrop', 'original')
	catch(FileNotFoundException) {
		println "Movie not found..."
		return null;

args.eachMediaFolder { dir ->
	def videos = dir.listFiles{ it.isVideo() }
        if (dir.hasFile{it =~ /nfo$/} || ( dir.hasFile{it =~ /banner.jpg$/} && dir.hasFile{it =~ /folder.jpg$/})) {
                println "Already scanned, skipping..."
	def query = _args.query ?:
	try {
		def options = TheMovieDB.searchMovie(query, _args.locale)
		if (options.isEmpty()) {
			println "Movie not found: $query"
			return null
		// sort by relevance
		options = options.sortBySimilarity(query, { })
		// auto-select series
		def movie = options[0]
		// 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);
			if (movie == null) return null
		println "$dir => $movie"
		fetchMovieArtworkAndNfo(dir, movie)
	catch(FileNotFoundException) {
		println "Movie not found: $query"
		return null;