* easy access to rename log from scripting
This commit is contained in:
parent
70aa36f3b7
commit
0490e2c770
|
@ -1,5 +1,5 @@
|
|||
|
||||
package net.sourceforge.filebot.ui.rename;
|
||||
package net.sourceforge.filebot;
|
||||
|
||||
|
||||
import static java.util.Collections.*;
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
package net.sourceforge.filebot.ui.rename;
|
||||
package net.sourceforge.filebot;
|
||||
|
||||
|
||||
import static net.sourceforge.filebot.History.*;
|
||||
import static net.sourceforge.filebot.Settings.*;
|
||||
import static net.sourceforge.filebot.ui.rename.History.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -13,24 +13,24 @@ import java.util.Map.Entry;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sourceforge.filebot.ui.rename.History.Element;
|
||||
import net.sourceforge.filebot.History.Element;
|
||||
|
||||
|
||||
public final class HistorySpooler {
|
||||
|
||||
private static final HistorySpooler instance = new HistorySpooler();
|
||||
|
||||
|
||||
|
||||
public static HistorySpooler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final File file = new File(getApplicationFolder(), "history.xml");
|
||||
|
||||
private final History sessionHistory = new History();
|
||||
|
||||
|
||||
|
||||
public synchronized History getCompleteHistory() {
|
||||
History history = new History();
|
||||
|
||||
|
@ -49,7 +49,12 @@ public final class HistorySpooler {
|
|||
return history;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public History getSessionHistory() {
|
||||
return sessionHistory;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void append(Iterable<Entry<File, File>> elements) {
|
||||
List<Element> sequence = new ArrayList<Element>();
|
||||
|
||||
|
@ -63,7 +68,7 @@ public final class HistorySpooler {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public synchronized void commit(History history) {
|
||||
try {
|
||||
exportHistory(history, file);
|
||||
|
@ -75,7 +80,7 @@ public final class HistorySpooler {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public synchronized void commit() {
|
||||
// check if session history is not empty
|
||||
if (sessionHistory.sequences().size() > 0) {
|
||||
|
@ -83,7 +88,7 @@ public final class HistorySpooler {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private HistorySpooler() {
|
||||
// commit session history on shutdown
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
|
@ -44,6 +44,7 @@ import java.util.logging.Level;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.filebot.Analytics;
|
||||
import net.sourceforge.filebot.HistorySpooler;
|
||||
import net.sourceforge.filebot.MediaTypes;
|
||||
import net.sourceforge.filebot.WebServices;
|
||||
import net.sourceforge.filebot.archive.Archive;
|
||||
|
@ -65,7 +66,6 @@ import net.sourceforge.filebot.similarity.SimilarityComparator;
|
|||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||
import net.sourceforge.filebot.subtitle.SubtitleFormat;
|
||||
import net.sourceforge.filebot.ui.Language;
|
||||
import net.sourceforge.filebot.ui.rename.HistorySpooler;
|
||||
import net.sourceforge.filebot.vfs.MemoryFile;
|
||||
import net.sourceforge.filebot.web.Episode;
|
||||
import net.sourceforge.filebot.web.EpisodeFormat;
|
||||
|
|
|
@ -152,6 +152,13 @@ File.metaClass.watch = { c -> createWatchService(c, [delegate], true) }
|
|||
List.metaClass.watch = { c -> createWatchService(c, delegate, true) }
|
||||
|
||||
|
||||
// Complete or session rename history
|
||||
def getRenameLog(complete = false) {
|
||||
def spooler = net.sourceforge.filebot.HistorySpooler.getInstance()
|
||||
def history = complete ? spooler.completeHistory : spooler.sessionHistory
|
||||
return history.sequences*.elements.flatten().collectEntries{ [new File(it.dir, it.from), new File(it.dir, it.to)] }
|
||||
}
|
||||
|
||||
// Season / Episode helpers
|
||||
import net.sourceforge.filebot.media.*
|
||||
import net.sourceforge.filebot.similarity.*
|
||||
|
|
|
@ -64,9 +64,10 @@ import javax.swing.table.TableModel;
|
|||
import javax.swing.table.TableRowSorter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sourceforge.filebot.History;
|
||||
import net.sourceforge.filebot.History.Element;
|
||||
import net.sourceforge.filebot.History.Sequence;
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.rename.History.Element;
|
||||
import net.sourceforge.filebot.ui.rename.History.Sequence;
|
||||
import net.sourceforge.filebot.ui.transfer.FileExportHandler;
|
||||
import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy;
|
||||
import net.sourceforge.filebot.ui.transfer.LoadAction;
|
||||
|
|
|
@ -42,6 +42,8 @@ import ca.odell.glazedlists.ListSelection;
|
|||
import ca.odell.glazedlists.swing.EventSelectionModel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sourceforge.filebot.History;
|
||||
import net.sourceforge.filebot.HistorySpooler;
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.filebot.Settings;
|
||||
import net.sourceforge.filebot.WebServices;
|
||||
|
|
Loading…
Reference in New Issue