* some improvements for amc processing logic

This commit is contained in:
Reinhard Pointner 2014-04-19 16:54:25 +00:00
parent 56ee173764
commit c5925ac3ac
5 changed files with 32 additions and 14 deletions

View File

@ -163,7 +163,7 @@ movies = tmdb.findResults{
movies = treeSort(movies, { it[3, 2].join(' ') })
// sanity check
if (movies.size() < 40000) { throw new Exception('Movie index sanity failed:' + movies.size()) }
if (movies.size() < 40000) { die('Movie index sanity failed:' + movies.size()) }
pack(moviedb_out, movies*.join('\t'))
@ -240,7 +240,7 @@ tvdb.values().each{ r ->
def addSeriesAlias = { from, to ->
def se = thetvdb_index.find{ from == it[1] && !it.contains(to) }
if (se == null) throw new Exception("Unabled to find series '${from}': '${to}'")
if (se == null) die("Unabled to find series '${from}': '${to}'")
thetvdb_index << [se[0], to]
}
@ -272,7 +272,7 @@ thetvdb_index = thetvdb_index.sort({ a, b -> a[0] <=> b[0] } as Comparator)
def thetvdb_txt = thetvdb_index.groupBy{ it[0] }.findResults{ k, v -> ([k.pad(6)] + v*.getAt(1).unique{ it.toLowerCase() }).join('\t') }
// sanity check
if (thetvdb_txt.size() < 4000) { throw new Exception('TheTVDB index sanity failed: ' + thetvdb_txt.size()) }
if (thetvdb_txt.size() < 4000) { die('TheTVDB index sanity failed: ' + thetvdb_txt.size()) }
pack(thetvdb_out, thetvdb_txt)
@ -294,5 +294,5 @@ def anidb_index = anidb.findResults{
def anidb_txt = anidb_index.findResults{ row -> row.join('\t') }.sort().unique()
// sanity check
if (anidb_txt.size() < 8000) { throw new Exception('AniDB index sanity failed:' + anidb_txt.size()) }
if (anidb_txt.size() < 8000) { die('AniDB index sanity failed:' + anidb_txt.size()) }
pack(anidb_out, anidb_txt)

View File

@ -10,6 +10,7 @@ import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -93,6 +94,10 @@ public final class HistorySpooler {
}
}
public synchronized void append(Map<File, File> elements) {
append(elements.entrySet());
}
public synchronized void append(Iterable<Entry<File, File>> elements) {
List<Element> sequence = new ArrayList<Element>();

View File

@ -107,17 +107,18 @@ public class ArgumentProcessor {
shell.runScript(script, bindings);
}
// script finished successfully
CLILogger.finest("Done ヾ(@⌒ー⌒@)");
return 0;
} catch (ScriptDeath e) {
CLILogger.log(Level.WARNING, e.getMessage());
} catch (Throwable e) {
if (e.getClass() == Exception.class) {
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)));
} else {
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e));
}
CLILogger.finest("Failure (°_°)");
return -1;
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e));
}
// script failed
CLILogger.finest("Failure (°_°)");
return -1;
}
public static class DefaultScriptProvider implements ScriptProvider {

View File

@ -0,0 +1,13 @@
package net.filebot.cli;
public class ScriptDeath extends Throwable {
public ScriptDeath(String message) {
super(message);
}
public ScriptDeath(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -44,7 +44,6 @@ import net.filebot.similarity.SeasonEpisodeMatcher.SxE;
import net.filebot.util.FileUtilities;
import net.filebot.web.Movie;
import org.codehaus.groovy.runtime.StackTraceUtils;
import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
import com.sun.jna.Platform;
@ -124,11 +123,11 @@ public abstract class ScriptShellBaseClass extends Script {
CLILogger.severe(String.format("%s: %s", t.getClass().getName(), t.getMessage()));
// DEBUG
StackTraceUtils.deepSanitize(t).printStackTrace();
// StackTraceUtils.deepSanitize(t).printStackTrace();
}
public void die(String message) throws Throwable {
throw new Exception(message);
throw new ScriptDeath(message);
}
// define global variable: _args