mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-15 13:55:03 -05:00
6d0d7ca75e
* support Mar.adentro.2004.HDTVRip.720p => The Sea Inside 2004 (@see http://www.filebot.net/forums/viewtopic.php?f=6&t=680&p=4512#p4512)
72 lines
1.6 KiB
Java
72 lines
1.6 KiB
Java
|
|
package net.sourceforge.filebot.media;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.attribute.BasicFileAttributeView;
|
|
import java.nio.file.attribute.FileTime;
|
|
|
|
import net.sourceforge.filebot.MetaAttributeView;
|
|
|
|
import com.cedarsoftware.util.io.JsonReader;
|
|
import com.cedarsoftware.util.io.JsonWriter;
|
|
|
|
|
|
public class MetaAttributes {
|
|
|
|
private static final String FILENAME_KEY = "filename";
|
|
private static final String METADATA_KEY = "metadata";
|
|
|
|
private final BasicFileAttributeView fileAttributeView;
|
|
private final MetaAttributeView metaAttributeView;
|
|
|
|
|
|
public MetaAttributes(File file) {
|
|
this.metaAttributeView = new MetaAttributeView(file);
|
|
this.fileAttributeView = Files.getFileAttributeView(file.toPath(), BasicFileAttributeView.class);
|
|
}
|
|
|
|
|
|
public void setCreationDate(long millis) throws IOException {
|
|
fileAttributeView.setTimes(null, null, FileTime.fromMillis(millis));
|
|
}
|
|
|
|
|
|
public long getCreationDate(long time) {
|
|
try {
|
|
return fileAttributeView.readAttributes().creationTime().toMillis();
|
|
} catch (Exception e) {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
public void setOriginalName(String name) {
|
|
metaAttributeView.put(FILENAME_KEY, name);
|
|
}
|
|
|
|
|
|
public String getOriginalName() {
|
|
return metaAttributeView.get(FILENAME_KEY);
|
|
}
|
|
|
|
|
|
public void setObject(Object object) {
|
|
metaAttributeView.put(METADATA_KEY, JsonWriter.toJson(object));
|
|
}
|
|
|
|
|
|
public Object getObject() {
|
|
return JsonReader.toJava(metaAttributeView.get(METADATA_KEY));
|
|
}
|
|
|
|
|
|
public void clear() {
|
|
metaAttributeView.remove(FILENAME_KEY);
|
|
metaAttributeView.remove(METADATA_KEY);
|
|
}
|
|
|
|
}
|