Explicitly add "Exif Metadata" to the Preset Editor
This commit is contained in:
parent
28c0d8ed7b
commit
7b7a75e694
|
@ -136,7 +136,7 @@ public class ImageMetadata {
|
|||
try {
|
||||
return Optional.ofNullable(extract.apply(metadata));
|
||||
} catch (Exception e) {
|
||||
debug.warning(e::toString);
|
||||
debug.finest(format("Failed to extract image metadata: %s", e));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 729 B |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -49,14 +49,14 @@ music.example[4]: {n}/{album+'/'}{pi.pad(2)+'. '} {t}
|
|||
music.example[5]: {home}/Media/{plex}
|
||||
|
||||
# simple filename without extension
|
||||
file.example[0]: {i.pad(3)} - {n}
|
||||
# simple filter
|
||||
file.example[1]: {n.after('-')}
|
||||
file.example[0]: {i.pad(3)} - {n.after('-')}
|
||||
# remove special characters
|
||||
file.example[2]: {n.ascii().normalizePunctuation().space('_')}
|
||||
file.example[1]: {n.ascii().normalizePunctuation().space('_')}
|
||||
# remove release info patterns
|
||||
file.example[3]: {n.stripReleaseInfo().space(' ')}
|
||||
file.example[2]: {n.stripReleaseInfo().space(' ')}
|
||||
# generate name from iTunes ID3 tags
|
||||
file.example[4]: {media.Album} - {media.PartID} - {media.Title}
|
||||
file.example[3]: {media.Album} - {media.PartID} - {media.Title}
|
||||
# restore original filename via embedded title metadata (if possible)
|
||||
file.example[5]: {any{mediaTitle}{n}}
|
||||
file.example[4]: {any{mediaTitle}{n}}
|
||||
# sort by Last-Modified or Date-Taken
|
||||
file.example[5]: {dt.format('yyyy-MM-dd HH\u2236mm\u2236ss')}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package net.filebot.ui.rename;
|
||||
|
||||
import static net.filebot.Logging.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import net.filebot.ResourceManager;
|
||||
import net.filebot.mediainfo.ImageMetadata;
|
||||
import net.filebot.similarity.Match;
|
||||
import net.filebot.web.Datasource;
|
||||
import net.filebot.web.SortOrder;
|
||||
|
||||
public class PhotoFileMatcher implements Datasource, AutoCompleteMatcher {
|
||||
|
||||
public static final PhotoFileMatcher INSTANCE = new PhotoFileMatcher();
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "exif";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Exif Metadata";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ResourceManager.getIcon("search.exif");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Match<File, ?>> match(Collection<File> files, boolean strict, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception {
|
||||
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
||||
|
||||
for (File f : filter(files, ImageMetadata.SUPPORTED_FILE_TYPES)) {
|
||||
try {
|
||||
ImageMetadata metadata = new ImageMetadata(f);
|
||||
if (metadata.getDateTaken().isPresent()) {
|
||||
matches.add(new Match<File, File>(f, f)); // photo mode is the same as generic file mode (but only select photo files)
|
||||
}
|
||||
} catch (Exception e) {
|
||||
debug.warning(format("%s [%s]", e, f));
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,8 @@ import net.filebot.web.SortOrder;
|
|||
|
||||
public class PlainFileMatcher implements Datasource, AutoCompleteMatcher {
|
||||
|
||||
public static final PlainFileMatcher INSTANCE = new PlainFileMatcher();
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "file";
|
||||
|
|
|
@ -18,7 +18,6 @@ import net.filebot.format.ExpressionFileFilter;
|
|||
import net.filebot.format.ExpressionFileFormat;
|
||||
import net.filebot.format.ExpressionFilter;
|
||||
import net.filebot.format.ExpressionFormat;
|
||||
import net.filebot.media.XattrMetaInfoProvider;
|
||||
import net.filebot.web.Datasource;
|
||||
import net.filebot.web.EpisodeListProvider;
|
||||
import net.filebot.web.MovieIdentificationService;
|
||||
|
@ -120,11 +119,12 @@ public class Preset {
|
|||
return new MusicMatcher((MusicIdentificationService) db);
|
||||
}
|
||||
|
||||
if (db instanceof XattrMetaInfoProvider) {
|
||||
return XATTR_FILE_MATCHER;
|
||||
// PhotoFileMatcher / XattrFileMatcher / PlainFileMatcher
|
||||
if (db instanceof AutoCompleteMatcher) {
|
||||
return (AutoCompleteMatcher) db;
|
||||
}
|
||||
|
||||
return PLAIN_FILE_MATCHER; // default to plain file matcher
|
||||
throw new IllegalStateException("Illegal datasource: " + db);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,13 +132,12 @@ public class Preset {
|
|||
return name;
|
||||
}
|
||||
|
||||
public static final XattrFileMatcher XATTR_FILE_MATCHER = new XattrFileMatcher();
|
||||
public static final PlainFileMatcher PLAIN_FILE_MATCHER = new PlainFileMatcher();
|
||||
|
||||
public static Datasource[] getSupportedServices() {
|
||||
Stream<Datasource> services = Stream.of(getEpisodeListProviders(), getMovieIdentificationServices(), getMusicIdentificationServices()).flatMap(Stream::of);
|
||||
services = Stream.concat(services, Stream.of(XATTR_FILE_MATCHER, PLAIN_FILE_MATCHER));
|
||||
return services.toArray(Datasource[]::new);
|
||||
return Stream.of(getEpisodeListProviders(), getMovieIdentificationServices(), getMusicIdentificationServices(), getGenericFileMatcherServices()).flatMap(Stream::of).toArray(Datasource[]::new);
|
||||
}
|
||||
|
||||
public static Datasource[] getGenericFileMatcherServices() {
|
||||
return new Datasource[] { PhotoFileMatcher.INSTANCE, XattrFileMatcher.INSTANCE, PlainFileMatcher.INSTANCE };
|
||||
}
|
||||
|
||||
public static StandardRenameAction[] getSupportedActions() {
|
||||
|
|
|
@ -13,6 +13,8 @@ import net.filebot.web.SortOrder;
|
|||
|
||||
public class XattrFileMatcher extends XattrMetaInfoProvider implements AutoCompleteMatcher {
|
||||
|
||||
public static final XattrFileMatcher INSTANCE = new XattrFileMatcher();
|
||||
|
||||
@Override
|
||||
public List<Match<File, ?>> match(Collection<File> files, boolean strict, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception {
|
||||
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
|
||||
|
|
Loading…
Reference in New Issue