From 7b7a75e69492c470b83f2c3658758ed1bf46f0e6 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 3 Mar 2017 21:19:52 +0800 Subject: [PATCH] Explicitly add "Exif Metadata" to the Preset Editor --- .../net/filebot/mediainfo/ImageMetadata.java | 2 +- source/net/filebot/resources/search.exif.png | Bin 0 -> 729 bytes .../net/filebot/resources/search.exif@2x.png | Bin 0 -> 1548 bytes .../filebot/ui/rename/FormatDialog.properties | 14 ++--- .../filebot/ui/rename/PhotoFileMatcher.java | 58 ++++++++++++++++++ .../filebot/ui/rename/PlainFileMatcher.java | 2 + source/net/filebot/ui/rename/Preset.java | 19 +++--- .../filebot/ui/rename/XattrFileMatcher.java | 2 + 8 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 source/net/filebot/resources/search.exif.png create mode 100644 source/net/filebot/resources/search.exif@2x.png create mode 100644 source/net/filebot/ui/rename/PhotoFileMatcher.java diff --git a/source/net/filebot/mediainfo/ImageMetadata.java b/source/net/filebot/mediainfo/ImageMetadata.java index e872d5a7..93c571c5 100644 --- a/source/net/filebot/mediainfo/ImageMetadata.java +++ b/source/net/filebot/mediainfo/ImageMetadata.java @@ -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(); } diff --git a/source/net/filebot/resources/search.exif.png b/source/net/filebot/resources/search.exif.png new file mode 100644 index 0000000000000000000000000000000000000000..0a7ef90073e69d60491d26bc46641558bda5b646 GIT binary patch literal 729 zcmV;~0w(>5P)gv(RQ~*3boXL z;0LrZ0#MW2}Y{qJO~nz>8lAhEhzLAX=eDS`ugqrl}~j zyY22w$C+s`MBikRo4tF_ojd2AJEJhhaFC_!IS(H_-cnWVNTWfw?%%uHDPoBylk86h zKj+TvTgpELrlz02;G3>D8jWTiXCz2@y&eplJ_WzGxyN!CzN~zO<2dqPRaI!3{t{Eu z&)EJ&C}j?D*><_i^0`&^V2()>{`QYDb2&yRk-3SdlT1&i)5v5pFbo6z{e!r9;~L7P zGD_tVK7Yz!p!P;Rt^1>>%3L3qlA~P6OlPWAOQWSTC$Yw6dDdV}5=C z!PXWW@9B{y{8Z`#a`~Lhaa>n^byZc6Or{V&8^^{*0j^82vXaHgV?CHzYr(FsTQWFQ zFW_pg2g@8AzA!Ac5VGk)u#u6ASX}%F!!#vOsZ7 zv|FvB(fA&)Fj z+}y^icPWHIhv5d23IAC=9l>A_9UOD{ z1T21#oC0GFIWj-r9E-*zHLuUW(XMVDYXPOSSwPd!-qyy)Ep%W!uP)@D=;PM*pO5jUa?t1eTYv!o(12EEkpV;%00000 LNkvXXu0mjfpI=I` literal 0 HcmV?d00001 diff --git a/source/net/filebot/resources/search.exif@2x.png b/source/net/filebot/resources/search.exif@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..e8608c239e525c9035c10a39e0cbbe464cf16236 GIT binary patch literal 1548 zcmV+n2J`ueP)Kz!xF7iKK$D5 zm!D>al#1R<8}8Ws%1dGw{*x*bxo^|Vx<+kBuP|3?i4!BAH4fo=9T*IaQ^%` zxLi($+6^H#>#Ml$cIcS=J zO7fGcw}6||>7>nF*tBI6h6aa3e{^&dYuBzN00xOk{*wg&ndGm(FXP(8HN@lbc?^Uj z5p;C4BiIxa^TN>>-VWr&STYl%gJ`JDzEuGB=}wz!OiWCOjaWz5io}Wo4x$Sq zBSuhCZ@fZaCqZouG~ zLA18DQIzK_0GeJ|0JwDN5;CbILeVxH8*^bO?na?hiDVb~KQf1HtGtL$Pts}2SlzW6 zW+g&-V}n4JYp(7h0H;o#sxsgrw{X*l0gi!GE{n;VH=wqx#OG%l(b5{j*1jlOVgX@y zb1I9`tJ5?#g;yVTlI<0!6s-P6zi=S~&<*{+Q!z8Zr&L2BI~fQU@cFNfPoQl@3_p!E zVqJF^dLCE_Z-W=vm}BzE2>=VKU z8ebjLUnN&8S3gS;8E>0};uA07Z5^;W4&hTiSj; z1GHA{Ex02C+)AYqbW?}Z<-sJ~>%Qh$0wqJ0og@l^vO@^>S;u2+!?rG`M?}6s{%7H} z%1dE@T~Hzym~?-m(J+QDj$mh30cTQijAt|iB_~=Hj}Y#&j>p)BZ6nbL&Ar6}ueGQk zxosYxbX;YCuA-`jDXOP&^jJUkZQqJ-M-tdOY+$yMh#JWJ`5p)Mt<&-2(SAxm#F84K zJaQ}fXxeR3F)LY^fwO~W#baa}G5~{UR1^o=THEo@^=tU<&=G8WWIbMdp%Y%Wm9PqP z8oj3DG&V$YCCaAlVvcEQ)wtueYOi4xfR*nJ4E#1At`7$uKST_|e!)1K1p)y|EUidT zJuqCO%6dNJsb(k?i}L_@iMdAF*hB8Ksx9js;BSs6i&be6fO0yWKGEOb zztPUwwXbBo!nL+GSlDcL)~x|)PClPMVb@4@P3WioeI${3fq9o3`ykFw3s*$dqO?+@ yc@|ZXcfaw;*>42_X1RYGO80)8E;oRG1sDLJI6MV&=6-$v0000> match(Collection files, boolean strict, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception { + List> matches = new ArrayList>(); + + for (File f : filter(files, ImageMetadata.SUPPORTED_FILE_TYPES)) { + try { + ImageMetadata metadata = new ImageMetadata(f); + if (metadata.getDateTaken().isPresent()) { + matches.add(new Match(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; + } + +} diff --git a/source/net/filebot/ui/rename/PlainFileMatcher.java b/source/net/filebot/ui/rename/PlainFileMatcher.java index 68ec530e..4addf231 100644 --- a/source/net/filebot/ui/rename/PlainFileMatcher.java +++ b/source/net/filebot/ui/rename/PlainFileMatcher.java @@ -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"; diff --git a/source/net/filebot/ui/rename/Preset.java b/source/net/filebot/ui/rename/Preset.java index a8f453c1..85e226da 100644 --- a/source/net/filebot/ui/rename/Preset.java +++ b/source/net/filebot/ui/rename/Preset.java @@ -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 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() { diff --git a/source/net/filebot/ui/rename/XattrFileMatcher.java b/source/net/filebot/ui/rename/XattrFileMatcher.java index dbb093bb..26c3edc4 100644 --- a/source/net/filebot/ui/rename/XattrFileMatcher.java +++ b/source/net/filebot/ui/rename/XattrFileMatcher.java @@ -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(Collection files, boolean strict, SortOrder order, Locale locale, boolean autodetection, Component parent) throws Exception { List> matches = new ArrayList>();