mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-09 22:09:47 -04:00
-DuseCreationDate=true
This commit is contained in:
parent
9574172b35
commit
6996914492
@ -15,6 +15,7 @@
|
||||
|
||||
# use NTFS extended attributes for storing metadata
|
||||
-DuseExtendedFileAttributes=true
|
||||
-DuseCreationDate=true
|
||||
|
||||
# look for native libs here
|
||||
-Djna.library.path="%EXEDIR%"
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
# use NTFS extended attributes for storing metadata
|
||||
-DuseExtendedFileAttributes=true
|
||||
-DuseCreationDate=true
|
||||
|
||||
# look for native libs here
|
||||
-Djna.library.path="%EXEDIR%"
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
# do not use NTFS extended attributes for storing metadata
|
||||
-DuseExtendedFileAttributes=false
|
||||
-DuseCreationDate=false
|
||||
|
||||
# look for native libs here
|
||||
-Djna.library.path="%EXEDIR%"
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
# do not use NTFS extended attributes for storing metadata
|
||||
-DuseExtendedFileAttributes=false
|
||||
-DuseCreationDate=false
|
||||
|
||||
# put all temporary files here
|
||||
-Djava.io.tmpdir="%EXEDIR%\temp"
|
||||
|
@ -156,6 +156,7 @@ public class Main {
|
||||
}
|
||||
if (args.disableExtendedAttributes) {
|
||||
System.setProperty("useExtendedFileAttributes", "false");
|
||||
System.setProperty("useCreationDate", "false");
|
||||
}
|
||||
if (args.action.equalsIgnoreCase("test")) {
|
||||
System.setProperty("useExtendedFileAttributes", "false");
|
||||
|
@ -1,7 +1,5 @@
|
||||
|
||||
package net.sourceforge.filebot;
|
||||
|
||||
|
||||
import static net.sourceforge.tuned.StringUtilities.*;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
@ -17,19 +15,16 @@ import net.sourceforge.tuned.PreferencesMap;
|
||||
import net.sourceforge.tuned.PreferencesMap.PreferencesEntry;
|
||||
import net.sourceforge.tuned.PreferencesMap.StringAdapter;
|
||||
|
||||
|
||||
public final class Settings {
|
||||
|
||||
public static String getApplicationName() {
|
||||
return getApplicationProperty("application.name");
|
||||
}
|
||||
|
||||
|
||||
public static String getApplicationVersion() {
|
||||
return getApplicationProperty("application.version");
|
||||
}
|
||||
|
||||
|
||||
public static int getApplicationRevisionNumber() {
|
||||
try {
|
||||
return Integer.parseInt(getApplicationProperty("application.revision"));
|
||||
@ -38,31 +33,29 @@ public final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getApplicationProperty(String key) {
|
||||
return ResourceBundle.getBundle(Settings.class.getName(), Locale.ROOT).getString(key);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isUnixFS() {
|
||||
return Boolean.parseBoolean(System.getProperty("unixfs"));
|
||||
}
|
||||
|
||||
|
||||
public static boolean useNativeShell() {
|
||||
return Boolean.parseBoolean(System.getProperty("useNativeShell"));
|
||||
}
|
||||
|
||||
|
||||
public static boolean useGVFS() {
|
||||
return Boolean.parseBoolean(System.getProperty("useGVFS"));
|
||||
}
|
||||
|
||||
|
||||
public static boolean useExtendedFileAttributes() {
|
||||
return Boolean.parseBoolean(System.getProperty("useExtendedFileAttributes"));
|
||||
}
|
||||
|
||||
public static boolean useCreationDate() {
|
||||
return Boolean.parseBoolean(System.getProperty("useCreationDate"));
|
||||
}
|
||||
|
||||
public static boolean useDonationReminder() {
|
||||
String deployment = getApplicationDeployment();
|
||||
@ -74,7 +67,6 @@ public final class Settings {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static int getPreferredThreadPoolSize() {
|
||||
try {
|
||||
return Integer.parseInt(System.getProperty("threadPool"));
|
||||
@ -83,7 +75,6 @@ public final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getApplicationDeployment() {
|
||||
String deployment = System.getProperty("application.deployment");
|
||||
if (deployment != null)
|
||||
@ -95,7 +86,6 @@ public final class Settings {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static File getApplicationFolder() {
|
||||
String applicationDirPath = System.getProperty("application.dir");
|
||||
File applicationFolder = null;
|
||||
@ -116,34 +106,28 @@ public final class Settings {
|
||||
return applicationFolder;
|
||||
}
|
||||
|
||||
|
||||
public static Settings forPackage(Class<?> type) {
|
||||
return new Settings(Preferences.userNodeForPackage(type));
|
||||
}
|
||||
|
||||
private final Preferences prefs;
|
||||
|
||||
|
||||
private Settings(Preferences prefs) {
|
||||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
|
||||
public Settings node(String nodeName) {
|
||||
return new Settings(prefs.node(nodeName));
|
||||
}
|
||||
|
||||
|
||||
public String get(String key) {
|
||||
return get(key, null);
|
||||
}
|
||||
|
||||
|
||||
public String get(String key, String def) {
|
||||
return prefs.get(key, def);
|
||||
}
|
||||
|
||||
|
||||
public void put(String key, String value) {
|
||||
if (value != null) {
|
||||
prefs.put(key, value);
|
||||
@ -152,27 +136,22 @@ public final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void remove(String key) {
|
||||
prefs.remove(key);
|
||||
}
|
||||
|
||||
|
||||
public PreferencesEntry<String> entry(String key) {
|
||||
return new PreferencesEntry<String>(prefs, key, new StringAdapter());
|
||||
}
|
||||
|
||||
|
||||
public PreferencesMap<String> asMap() {
|
||||
return PreferencesMap.map(prefs);
|
||||
}
|
||||
|
||||
|
||||
public PreferencesList<String> asList() {
|
||||
return PreferencesList.map(prefs);
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
try {
|
||||
// remove child nodes
|
||||
@ -187,12 +166,10 @@ public final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getApplicationIdentifier() {
|
||||
return joinBy(" ", getApplicationName(), getApplicationVersion(), String.format("(r%s)", getApplicationRevisionNumber()));
|
||||
}
|
||||
|
||||
|
||||
public static String getJavaRuntimeIdentifier() {
|
||||
String name = System.getProperty("java.runtime.name");
|
||||
String version = System.getProperty("java.version");
|
||||
|
@ -609,7 +609,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
}
|
||||
|
||||
// write metadata into xattr if xattr is enabled
|
||||
if (matches != null && useExtendedFileAttributes()) {
|
||||
if (matches != null && (useExtendedFileAttributes() || useCreationDate())) {
|
||||
try {
|
||||
for (Match<File, ?> match : matches) {
|
||||
File file = match.getValue();
|
||||
@ -617,7 +617,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
if (renameMap.containsKey(file) && meta != null) {
|
||||
File destination = resolveDestination(file, renameMap.get(file), false);
|
||||
if (destination.isFile()) {
|
||||
MediaDetection.storeMetaInfo(destination, meta, file.getName());
|
||||
MediaDetection.storeMetaInfo(destination, meta, file.getName(), useExtendedFileAttributes(), useCreationDate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package net.sourceforge.filebot.format;
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Collections.*;
|
||||
import static net.sourceforge.filebot.MediaTypes.*;
|
||||
import static net.sourceforge.filebot.Settings.*;
|
||||
import static net.sourceforge.filebot.format.Define.*;
|
||||
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
|
||||
import static net.sourceforge.filebot.media.MediaDetection.*;
|
||||
@ -358,13 +357,13 @@ public class MediaBindingBean {
|
||||
}
|
||||
|
||||
@Define("original")
|
||||
public String getOriginalFileName() {
|
||||
public String getOriginalFileName() throws Exception {
|
||||
return getOriginalFileName(mediaFile);
|
||||
}
|
||||
|
||||
@Define("xattr")
|
||||
public Object getMetaAttributesObject() {
|
||||
return getMetaAttributesObject(mediaFile);
|
||||
public Object getMetaAttributesObject() throws Exception {
|
||||
return new MetaAttributes(mediaFile).getObject();
|
||||
}
|
||||
|
||||
@Define("crc32")
|
||||
@ -860,25 +859,11 @@ public class MediaBindingBean {
|
||||
}
|
||||
|
||||
private String getOriginalFileName(File file) {
|
||||
if (useExtendedFileAttributes()) {
|
||||
try {
|
||||
return new MetaAttributes(file).getOriginalName();
|
||||
} catch (Throwable e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object getMetaAttributesObject(File file) {
|
||||
if (useExtendedFileAttributes()) {
|
||||
try {
|
||||
return new MetaAttributes(file).getObject();
|
||||
} catch (Throwable e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1312,13 +1312,14 @@ public class MediaDetection {
|
||||
}
|
||||
};
|
||||
|
||||
public static void storeMetaInfo(File file, Object model, String original) {
|
||||
public static void storeMetaInfo(File file, Object model, String original, boolean useExtendedFileAttributes, boolean useCreationDate) {
|
||||
// only for Episode / Movie objects
|
||||
if ((model instanceof Episode || model instanceof Movie) && file.exists()) {
|
||||
if ((useExtendedFileAttributes || useCreationDate) && (model instanceof Episode || model instanceof Movie) && file.isFile()) {
|
||||
try {
|
||||
MetaAttributes xattr = new MetaAttributes(file);
|
||||
|
||||
// set creation date to episode / movie release date
|
||||
if (useCreationDate) {
|
||||
try {
|
||||
if (model instanceof Episode) {
|
||||
Episode episode = (Episode) model;
|
||||
@ -1334,8 +1335,10 @@ public class MediaDetection {
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set creation date: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// store original name and model as xattr
|
||||
if (useExtendedFileAttributes) {
|
||||
try {
|
||||
xattr.setObject(model);
|
||||
if (xattr.getOriginalName() == null && original != null) {
|
||||
@ -1344,6 +1347,7 @@ public class MediaDetection {
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set xattr: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
Logger.getLogger(MediaDetection.class.getClass().getName()).warning(t.toString());
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class RenameAction extends AbstractAction {
|
||||
}
|
||||
|
||||
// write metadata into xattr if xattr is enabled
|
||||
if (useExtendedFileAttributes()) {
|
||||
if (useExtendedFileAttributes() || useCreationDate()) {
|
||||
try {
|
||||
for (Match<Object, File> match : matches) {
|
||||
File file = match.getCandidate();
|
||||
@ -123,7 +123,7 @@ class RenameAction extends AbstractAction {
|
||||
if (renameMap.containsKey(file) && meta != null) {
|
||||
File destination = resolveDestination(file, renameMap.get(file), false);
|
||||
if (destination.isFile()) {
|
||||
MediaDetection.storeMetaInfo(destination, meta, file.getName());
|
||||
MediaDetection.storeMetaInfo(destination, meta, file.getName(), useExtendedFileAttributes(), useCreationDate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1284,6 +1284,7 @@ LeON
|
||||
LEVERAGE
|
||||
LEViTY
|
||||
LF
|
||||
LFF
|
||||
LGLuX
|
||||
Lightmaker
|
||||
lilwoodenboy
|
||||
@ -2338,6 +2339,7 @@ x4subs
|
||||
XanaX
|
||||
xander
|
||||
XC
|
||||
Xell
|
||||
XF
|
||||
XiA
|
||||
XII
|
||||
|
Loading…
x
Reference in New Issue
Block a user