mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-14 05:15:03 -05:00
+ Add {history} binding to access the original historic path of {f} (e.g. useful for -exec post-processing calls)
This commit is contained in:
parent
c9876e093e
commit
672c015696
@ -14,6 +14,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.Marshaller;
|
import javax.xml.bind.Marshaller;
|
||||||
@ -181,7 +182,7 @@ public class History {
|
|||||||
|
|
||||||
public Map<File, File> getRenameMap() {
|
public Map<File, File> getRenameMap() {
|
||||||
Map<File, File> map = new LinkedHashMap<File, File>();
|
Map<File, File> map = new LinkedHashMap<File, File>();
|
||||||
for (History.Sequence seq : this.sequences()) {
|
for (History.Sequence seq : sequences) {
|
||||||
for (History.Element elem : seq.elements()) {
|
for (History.Element elem : seq.elements()) {
|
||||||
File to = new File(elem.to());
|
File to = new File(elem.to());
|
||||||
if (!to.isAbsolute()) {
|
if (!to.isAbsolute()) {
|
||||||
@ -194,6 +195,16 @@ public class History {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Stream<File> getOriginalPath(File destination) {
|
||||||
|
return sequences.stream().flatMap(s -> s.elements().stream()).filter(e -> {
|
||||||
|
File to = new File(e.to());
|
||||||
|
if (!to.isAbsolute()) {
|
||||||
|
to = new File(e.dir(), e.to());
|
||||||
|
}
|
||||||
|
return destination.equals(to);
|
||||||
|
}).map(e -> new File(e.dir(), e.from()));
|
||||||
|
}
|
||||||
|
|
||||||
public static void exportHistory(History history, OutputStream output) {
|
public static void exportHistory(History history, OutputStream output) {
|
||||||
try {
|
try {
|
||||||
Marshaller marshaller = JAXBContext.newInstance(History.class).createMarshaller();
|
Marshaller marshaller = JAXBContext.newInstance(History.class).createMarshaller();
|
||||||
|
@ -46,6 +46,7 @@ import com.github.benmanes.caffeine.cache.Cache;
|
|||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
|
|
||||||
import net.filebot.ApplicationFolder;
|
import net.filebot.ApplicationFolder;
|
||||||
|
import net.filebot.HistorySpooler;
|
||||||
import net.filebot.Language;
|
import net.filebot.Language;
|
||||||
import net.filebot.MediaTypes;
|
import net.filebot.MediaTypes;
|
||||||
import net.filebot.Resource;
|
import net.filebot.Resource;
|
||||||
@ -488,6 +489,18 @@ public class MediaBindingBean {
|
|||||||
return name != null ? getNameWithoutExtension(name) : null;
|
return name != null ? getNameWithoutExtension(name) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Define("history")
|
||||||
|
public File getOriginalFilePath() throws Exception {
|
||||||
|
// check in-memory history first
|
||||||
|
Optional<File> path = HistorySpooler.getInstance().getSessionHistory().getOriginalPath(getMediaFile()).findFirst();
|
||||||
|
if (path.isPresent()) {
|
||||||
|
return path.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check persistent history file as well
|
||||||
|
return HistorySpooler.getInstance().getCompleteHistory().getOriginalPath(getMediaFile()).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Define("xattr")
|
@Define("xattr")
|
||||||
public Object getMetaAttributesObject() throws Exception {
|
public Object getMetaAttributesObject() throws Exception {
|
||||||
return xattr.getMetaInfo(getMediaFile());
|
return xattr.getMetaInfo(getMediaFile());
|
||||||
|
Loading…
Reference in New Issue
Block a user