[Script] Fetch Artwork Collection

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
User avatar
rednoah
The Source
Posts: 24033
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[Script] Fetch Artwork Collection

Post by rednoah »

Fetch Movie Artwork Collection

e.g. Fetch artwork and fanart for newly processed movie files:
** requires FileBot r10652 or higher

Groovy: Select all

{ source, target, metadata ->
	// select artwork and fanart
	list{ movie.artwork }{ movie.fanart }
	// filter out non-English artwork
	.findAll{ a -> a.language == null || a.language ==~ /en/ }
	// group by artwork type (e.g. posters, backdrops)
	.groupBy{ a -> a.tags.join('_') }
	.each{ group, artwork ->
		// fetch the top 5 entries for each artwork type
		artwork.take(5).eachWithIndex{ a, i ->
			// target.dir is the movie folder
			curl a.url, target.dir / 'artwork' / "${group}-${i+1}.${a.extension}"
		}
	}
}


Fetch Series Artwork Collection

e.g. Fetch artwork and fanart for newly processed series / episode files:
** requires FileBot r10652 or higher

Groovy: Select all

{ source, target, metadata ->
	// select artwork and fanart
	list{ series.artwork }{ series.fanart }
	// filter out non-English artwork
	.findAll{ a -> a.language == null || a.language ==~ /en/ }
	// group by artwork type (e.g. posters, backdrops, seasonposter/1, seasonposter/2, etc) but not artwork size (e.g. 1000x1500)
	.groupBy{ a -> a.tags.grep(~/[a-z]+|[0-9]+/).join('_') }
	.each{ group, artwork ->
		// fetch the top 5 entries for each artwork type
		artwork.take(5).eachWithIndex{ a, i ->
			// target.dir.dir is the series folder
			curl a.url, target.dir.dir / 'artwork' / "${group}-${i+1}.${a.extension}"
		}
	}
}


List Artwork Collection

e.g. List all available artwork:

Groovy: Select all

{ source, target, metadata ->
	list{ movie.artwork }{ movie.fanart }{ series.artwork }{ series.fanart }
	.each{ a -> println a }
}
:idea: Please read the FAQ and How to Request Help.
Post Reply