* added TheMovieDB artwork fetcher

* move shared scripts folder
This commit is contained in:
Reinhard Pointner 2011-12-27 18:54:25 +00:00
parent 30e582b02e
commit 43f844b6f3
16 changed files with 97 additions and 20 deletions

View File

@ -443,6 +443,7 @@
<include name="*.ico" />
<include name="images/**" />
<include name="data/**" />
<include name="scripts/**" />
<include name="screenshots/**" />
</fileset>
</copy>

View File

@ -148,6 +148,10 @@ def similarity(o1, o2) {
return new NameSimilarityMetric().getSimilarity(o1, o2)
}
List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> obj } ->
return delegate.sort{ a, b -> similarity(toStringFunction(b), prime).compareTo(similarity(toStringFunction(a), prime)) }
}
// CLI bindings

View File

@ -75,7 +75,7 @@
<div class="content">
<div class="section screenshot" style="border:none; box-shadow:none; background:white; margin-left: 20px">
<a href="http://filebot.sourceforge.net/data/shell/" target="_blank"><img alt="See Examples" src="images/script.png" /></a>
<a href="http://filebot.sourceforge.net/scripts/" target="_blank"><img alt="See Examples" src="images/script.png" /></a>
<span class="quote">Anything is possible</span>
</div>
<div class="section about">

View File

@ -0,0 +1,72 @@
// filebot -script "http://filebot.sf.net/scripts/artwork.tmdb.groovy" -trust-script /path/to/media/
// EXPERIMENTAL // HERE THERE BE DRAGONS
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 802) throw new Exception("Application revision too old")
/*
* Fetch series and season banners for all tv shows
*/
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) {
movieInfo.applyXmlTemplate('''<movie>
<title>$name</title>
<year>${released?.year}</year>
<rating>$rating</rating>
<votes>$votes</votes>
<plot>$overview</plot>
<runtime>$runtime</runtime>
<mpaa>$certification</mpaa>
<genre>${genres.size() > 0 ? genres.get(0) : ''}</genre>
<id>tt${imdbId.pad(7)}</id>
</movie>
''').saveAs(outputFile)
}
def fetchMovieArtworkAndNfo(movieDir, movie) {
println "Fetch nfo and artwork for $movie"
def movieInfo = TheMovieDB.getMovieInfo(movie, Locale.ENGLISH)
// 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')
}
def jobs = args.getFolders().findResults { dir ->
def videos = dir.listFiles{ it.isVideo() }
if (videos.isEmpty()) {
return null
}
def query = _args.query ?: dir.name
def options = TheMovieDB.searchMovie(query, Locale.ENGLISH)
if (options.isEmpty()) {
println "Movie not found: $query"
return null
}
// auto-select series
def movie = options.sortBySimilarity(query, { it.name })[0]
return { fetchMovieArtworkAndNfo(dir, movie) }
}
parallel(jobs, 10)

View File

@ -1,7 +1,7 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/banners.groovy" -trust-script /path/to/media/
// filebot -script "http://filebot.sf.net/scripts/artwork.tvdb.groovy" -trust-script /path/to/media/
// EXPERIMENTAL // HERE THERE BE DRAGONS
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 783) throw new Exception("Application revision too old")
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 802) throw new Exception("Application revision too old")
/*
@ -16,7 +16,7 @@ def fetchBanner(outputFile, series, bannerType, bannerType2, season = null) {
return null
}
println "Fetching banner $banner"
println "Fetching $outputFile => $banner"
return banner.url.saveAs(outputFile)
}
@ -48,7 +48,7 @@ def fetchNfo(outputFile, series) {
def fetchSeriesBannersAndNfo(seriesDir, seasonDir, series, season) {
println "Fetch nfo and banners for $series / Season $season"
// fetch nfo
fetchNfo(seriesDir['tvshow.nfo'], series)
@ -77,21 +77,21 @@ def jobs = args.getFolders().findResults { dir ->
def sxe = videos.findResult{ parseEpisodeNumber(it) }
if (query == null) {
query = dir.dir.hasFile{ it.name =~ /Season.\d+/ } ? dir.dir.name : dir.name
query = dir.dir.hasFile{ it.name =~ /Season/ && it.isDirectory() } ? dir.dir.name : dir.name
println "Failed to detect series name from video files -> Query by $query instead"
}
def options = TheTVDB.search(query, Locale.ENGLISH)
if (options.isEmpty()) {
println "TV Series not found: $query"
return null;
return null
}
// auto-select series
def series = options[0]
def series = options.sortBySimilarity(query, { it.name })[0]
// auto-detect structure
def seriesDir = [dir.dir, dir].sort{ a, b -> similarity(b.name, series.name).compareTo(similarity(a.name, series.name)) }[0]
def seriesDir = [dir.dir, dir].sortBySimilarity(series.name, { it.name })[0]
def season = sxe && sxe.season > 0 ? sxe.season : 1
return { fetchSeriesBannersAndNfo(seriesDir, dir, series, season) }

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/chkall.groovy" <folder>
// filebot -script "http://filebot.sf.net/scripts/chkall.groovy" <folder>
/*
* Check all sfv/md5/sha1 files and stop if a conflict is found

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/cleaner.groovy" -trust-script /path/to/media/
// filebot -script "http://filebot.sf.net/scripts/cleaner.groovy" -trust-script /path/to/media/
/*
* Delete orphaned "clutter" files like nfo, jpg, etc

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/housekeeping.groovy" <folder>
// filebot -script "http://filebot.sf.net/scripts/housekeeping.groovy" <folder>
// EXPERIMENTAL // HERE THERE BE DRAGONS
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 783) throw new Exception("Revision 783+ required")
@ -10,7 +10,7 @@ if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 783) throw new
*/
// check for new media files once every 5 seconds
def updateFrequency = 5 * 1000;
def updateFrequency = 5 * 1000
// V:/TV Shows/Stargate/Season 1/Stargate.S01E01.Pilot
def episodeFormat = "{com.sun.jna.Platform.isWindows() ? file[0] : home}/TV Shows/{n}{'/Season '+s}/{n.space('.')}.{s00e00}.{t.space('.')}"

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/mi.groovy" -trust-script /path/to/media/ "MediaIndex.csv"
// filebot -script "http://filebot.sf.net/scripts/mi.groovy" -trust-script /path/to/media/ "MediaIndex.csv"
/*
* Print media info of all video files to CSV file

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/renall.groovy" <options> <folder>
// filebot -script "http://filebot.sf.net/scripts/renall.groovy" <options> <folder>
/*
* Rename all tv shows, anime or movies using given or default options

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/rsam.groovy" <options> <folder>
// filebot -script "http://filebot.sf.net/scripts/rsam.groovy" <options> <folder>
// EXPERIMENTAL // HERE THERE BE DRAGONS
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 783) throw new Exception("Revision 783+ required")

View File

@ -7,7 +7,7 @@ def movieDir = "V:/in/Movies"
def movieFormat = "V:/out/Movies/{movie}/{movie}"
// ignore chunk, part, par and hidden files
def incomplete(f) { f.name =~ /[.]chunk|[.]part\d{0,3}$|[.]par$/ || f.isHidden() }
def incomplete(f) { f.name =~ /[.]chunk|[.]part\d{0,3}$|[.]par$|[.]dat$/ || f.isHidden() }
// run cmdline unrar (require -trust-script) on multi-volume rar files

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/src.groovy" <folder>
// filebot -script "http://filebot.sf.net/scripts/src.groovy" <folder>
/*
* Fetch subtitles, rename and calculate checksums for all video files

View File

@ -1,4 +1,4 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/suball.groovy" <options> <folder>
// filebot -script "http://filebot.sf.net/scripts/suball.groovy" <options> <folder>
/*
* Get subtitles for all your media files

View File

@ -45,7 +45,7 @@
<changefreq>weekly</changefreq>
</url>
<url>
<loc>http://filebot.sourceforge.net/data/shell/</loc>
<loc>http://filebot.sourceforge.net/scripts/</loc>
<changefreq>weekly</changefreq>
</url>
</urlset>