mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 05:48:01 -05:00
* pass locale into scripting env
This commit is contained in:
parent
c0d0022907
commit
9277722163
@ -94,7 +94,7 @@ public class Main {
|
||||
// CLI mode => run command-line interface and then exit
|
||||
if (args.runCLI()) {
|
||||
// default cross-platform laf used in scripting to nimbus instead of metal (if possible)
|
||||
if (args.script != null) {
|
||||
if (args.script != null && !isHeadless()) {
|
||||
try {
|
||||
Class<?> nimbusLook = Class.forName("javax.swing.plaf.nimbus.NimbusLookAndFeel", false, Thread.currentThread().getContextClassLoader());
|
||||
System.setProperty("swing.crossplatformlaf", nimbusLook.getName());
|
||||
|
@ -12,6 +12,7 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.kohsuke.args4j.Argument;
|
||||
@ -88,32 +89,32 @@ public class ArgumentBean {
|
||||
@Argument
|
||||
public List<String> arguments = new ArrayList<String>();
|
||||
|
||||
|
||||
|
||||
public boolean runCLI() {
|
||||
return rename || getSubtitles || getMissingSubtitles || check || list || mediaInfo || script != null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean openSFV() {
|
||||
return open && containsOnly(getFiles(false), MediaTypes.getDefaultFilter("verification"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean printVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean printHelp() {
|
||||
return help;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean clearUserData() {
|
||||
return clear;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<File> getFiles(boolean resolveFolders) {
|
||||
List<File> files = new ArrayList<File>();
|
||||
|
||||
@ -132,7 +133,7 @@ public class ArgumentBean {
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public URL getScriptLocation() {
|
||||
try {
|
||||
return new URL(script);
|
||||
@ -149,7 +150,12 @@ public class ArgumentBean {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Locale getLocale() {
|
||||
return new Locale(lang);
|
||||
}
|
||||
|
||||
|
||||
public Level getLogLevel() {
|
||||
return Level.parse(log.toUpperCase());
|
||||
}
|
||||
|
@ -146,13 +146,13 @@ def parseDate(path) {
|
||||
return new DateMetric().parse(input)
|
||||
}
|
||||
|
||||
def detectSeriesName(files) {
|
||||
def names = MediaDetection.detectSeriesNames(files.findAll { it.isVideo() || it.isSubtitle() })
|
||||
def detectSeriesName(files, locale = Locale.ENGLISH) {
|
||||
def names = MediaDetection.detectSeriesNames(files.findAll { it.isVideo() || it.isSubtitle() }, locale)
|
||||
return names == null || names.isEmpty() ? null : names.toList()[0]
|
||||
}
|
||||
|
||||
def detectMovie(movieFile, strict = false) {
|
||||
def movies = MediaDetection.detectMovie(movieFile, OpenSubtitles, TheMovieDB, Locale.ENGLISH, strict)
|
||||
def detectMovie(movieFile, strict = false, locale = Locale.ENGLISH) {
|
||||
def movies = MediaDetection.detectMovie(movieFile, OpenSubtitles, TheMovieDB, locale, strict)
|
||||
return movies == null || movies.isEmpty() ? null : movies.toList()[0]
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ def similarity(o1, o2) {
|
||||
return new NameSimilarityMetric().getSimilarity(o1, o2)
|
||||
}
|
||||
|
||||
List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> obj } ->
|
||||
List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> obj.toString() } ->
|
||||
return delegate.sort{ a, b -> similarity(toStringFunction(b), prime).compareTo(similarity(toStringFunction(a), prime)) }
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// 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 < 836) throw new Exception("Application revision too old")
|
||||
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 838) throw new Exception("Application revision too old")
|
||||
|
||||
|
||||
/*
|
||||
@ -59,7 +59,7 @@ args.eachMediaFolder { dir ->
|
||||
def videos = dir.listFiles{ it.isVideo() }
|
||||
|
||||
def query = _args.query ?: dir.name
|
||||
def options = TheMovieDB.searchMovie(query, Locale.ENGLISH)
|
||||
def options = TheMovieDB.searchMovie(query, _args.locale)
|
||||
if (options.isEmpty()) {
|
||||
println "Movie not found: $query"
|
||||
return null
|
||||
@ -71,9 +71,9 @@ args.eachMediaFolder { dir ->
|
||||
// auto-select series
|
||||
def movie = options[0]
|
||||
|
||||
// require user input
|
||||
if (options.size != 1 && !java.awt.GraphicsEnvironment.headless) {
|
||||
movie = javax.swing.JOptionPane.showInputDialog(null, "Please select movie:", dir.path, 3, null, options.toArray(), movie);
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// 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 < 815) throw new Exception("Application revision too old")
|
||||
if (net.sourceforge.filebot.Settings.applicationRevisionNumber < 838) throw new Exception("Application revision too old")
|
||||
|
||||
/*
|
||||
* Fetch series and season banners for all tv shows. Series name is auto-detected if possible or the folder name is used.
|
||||
@ -21,7 +21,7 @@ def fetchBanner(outputFile, series, bannerType, bannerType2 = null, season = nul
|
||||
|
||||
|
||||
def fetchNfo(outputFile, series) {
|
||||
def info = TheTVDB.getSeriesInfo(series, Locale.ENGLISH)
|
||||
def info = TheTVDB.getSeriesInfo(series, _args.locale)
|
||||
println info
|
||||
info.applyXmlTemplate('''<tvshow xmlns:gsp='http://groovy.codehaus.org/2005/gsp'>
|
||||
<title>$name</title>
|
||||
@ -75,7 +75,7 @@ def fetchSeriesBannersAndNfo(seriesDir, seasonDir, series, season) {
|
||||
args.eachMediaFolder { dir ->
|
||||
def videos = dir.listFiles{ it.isVideo() }
|
||||
|
||||
def query = _args.query ?: detectSeriesName(videos)
|
||||
def query = _args.query ?: detectSeriesName(videos, _args.locale)
|
||||
def sxe = videos.findResult{ parseEpisodeNumber(it) }
|
||||
|
||||
if (query == null) {
|
||||
@ -83,14 +83,23 @@ args.eachMediaFolder { dir ->
|
||||
}
|
||||
|
||||
println "$dir => Search by $query"
|
||||
def options = TheTVDB.search(query, Locale.ENGLISH)
|
||||
def options = TheTVDB.search(query, _args.locale)
|
||||
if (options.isEmpty()) {
|
||||
println "TV Series not found: $query"
|
||||
return null
|
||||
}
|
||||
|
||||
// sort by relevance
|
||||
options = options.sortBySimilarity(query, { it.name })
|
||||
|
||||
// auto-select series
|
||||
def series = options.sortBySimilarity(query, { it.name })[0]
|
||||
def series = options[0]
|
||||
|
||||
// maybe require user input
|
||||
if (options.size() != 1 && !_args.nonStrict && !java.awt.GraphicsEnvironment.headless) {
|
||||
series = javax.swing.JOptionPane.showInputDialog(null, "Please select TV Show:", dir.path, 3, null, options.toArray(), series);
|
||||
if (series == null) return null
|
||||
}
|
||||
|
||||
// auto-detect structure
|
||||
def seriesDir = [dir.dir, dir].sortBySimilarity(series.name, { it.name })[0]
|
||||
|
Loading…
Reference in New Issue
Block a user