* better samples for format expression testing environment
This commit is contained in:
parent
eb0027d691
commit
e90a076729
|
@ -128,6 +128,7 @@ class BindingDialog extends JDialog {
|
||||||
mediaFileTextField.getDocument().addDocumentListener(changeListener);
|
mediaFileTextField.getDocument().addDocumentListener(changeListener);
|
||||||
|
|
||||||
// disabled by default
|
// disabled by default
|
||||||
|
infoTextField.setEnabled(false);
|
||||||
mediaInfoAction.setEnabled(false);
|
mediaInfoAction.setEnabled(false);
|
||||||
|
|
||||||
// disable media info action if media file is invalid
|
// disable media info action if media file is invalid
|
||||||
|
@ -236,6 +237,7 @@ class BindingDialog extends JDialog {
|
||||||
|
|
||||||
|
|
||||||
public void setInfoObject(Object info) {
|
public void setInfoObject(Object info) {
|
||||||
|
infoTextField.putClientProperty("model", info);
|
||||||
infoTextField.setText(info == null ? "" : infoObjectFormat.format(info));
|
infoTextField.setText(info == null ? "" : infoObjectFormat.format(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,18 +248,7 @@ class BindingDialog extends JDialog {
|
||||||
|
|
||||||
|
|
||||||
public Object getInfoObject() {
|
public Object getInfoObject() {
|
||||||
try {
|
return infoTextField.getClientProperty("model");
|
||||||
// try known object
|
|
||||||
Object model = infoTextField.getClientProperty("model");
|
|
||||||
if (model != null) {
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
// or parse user input
|
|
||||||
return infoObjectFormat.parseObject(infoTextField.getText());
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,19 +389,15 @@ class BindingDialog extends JDialog {
|
||||||
// set file
|
// set file
|
||||||
mediaFileTextField.setText(file.getAbsolutePath());
|
mediaFileTextField.setText(file.getAbsolutePath());
|
||||||
|
|
||||||
// reset known model
|
|
||||||
infoTextField.putClientProperty("model", null);
|
|
||||||
infoTextField.setEnabled(true);
|
|
||||||
|
|
||||||
// set info object from xattr if possible
|
// set info object from xattr if possible
|
||||||
if (useExtendedFileAttributes()) {
|
if (useExtendedFileAttributes()) {
|
||||||
try {
|
try {
|
||||||
MetaAttributes xattr = new MetaAttributes(file);
|
MetaAttributes xattr = new MetaAttributes(file);
|
||||||
try {
|
try {
|
||||||
Object object = xattr.getMetaData();
|
Object object = xattr.getMetaData();
|
||||||
infoTextField.setText(infoObjectFormat.format(object));
|
if (infoObjectFormat.format(object) != null) {
|
||||||
infoTextField.putClientProperty("model", object);
|
setInfoObject(object);
|
||||||
infoTextField.setEnabled(false);
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore invalid data
|
// ignore invalid data
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.beans.PropertyChangeListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.text.Format;
|
import java.text.Format;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
@ -79,6 +78,9 @@ import net.sourceforge.tuned.ui.TunedUtilities;
|
||||||
import net.sourceforge.tuned.ui.notification.SeparatorBorder;
|
import net.sourceforge.tuned.ui.notification.SeparatorBorder;
|
||||||
import net.sourceforge.tuned.ui.notification.SeparatorBorder.Position;
|
import net.sourceforge.tuned.ui.notification.SeparatorBorder.Position;
|
||||||
|
|
||||||
|
import com.cedarsoftware.util.io.JsonReader;
|
||||||
|
import com.cedarsoftware.util.io.JsonWriter;
|
||||||
|
|
||||||
|
|
||||||
class FormatDialog extends JDialog {
|
class FormatDialog extends JDialog {
|
||||||
|
|
||||||
|
@ -386,14 +388,17 @@ class FormatDialog extends JDialog {
|
||||||
try {
|
try {
|
||||||
// restore sample from user preferences
|
// restore sample from user preferences
|
||||||
String sample = mode.persistentSample().getValue();
|
String sample = mode.persistentSample().getValue();
|
||||||
info = mode.getFormat().parseObject(sample);
|
info = JsonReader.toJava(sample);
|
||||||
|
if (info == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
// restore sample from application properties
|
// restore sample from application properties
|
||||||
ResourceBundle bundle = ResourceBundle.getBundle(getClass().getName());
|
ResourceBundle bundle = ResourceBundle.getBundle(getClass().getName());
|
||||||
String sample = bundle.getString(mode.key() + ".sample");
|
String sample = bundle.getString(mode.key() + ".sample");
|
||||||
info = mode.getFormat().parseObject(sample);
|
info = JsonReader.toJava(sample);
|
||||||
} catch (ParseException illegalSample) {
|
} catch (Exception illegalSample) {
|
||||||
throw new RuntimeException(illegalSample); // won't happen
|
throw new RuntimeException(illegalSample); // won't happen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,7 +618,7 @@ class FormatDialog extends JDialog {
|
||||||
sample = new MediaBindingBean(info, file, null);
|
sample = new MediaBindingBean(info, file, null);
|
||||||
|
|
||||||
// remember
|
// remember
|
||||||
mode.persistentSample().setValue(info == null ? "" : mode.getFormat().format(info));
|
mode.persistentSample().setValue(info == null ? "" : JsonWriter.toJson(info));
|
||||||
persistentSampleFile.setValue(file == null ? "" : sample.getMediaFile().getAbsolutePath());
|
persistentSampleFile.setValue(file == null ? "" : sample.getMediaFile().getAbsolutePath());
|
||||||
|
|
||||||
// reevaluate everything
|
// reevaluate everything
|
||||||
|
|
|
@ -2,11 +2,11 @@ help.url = http://filebot.sourceforge.net/naming.html
|
||||||
|
|
||||||
episode.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 name, <b>s</b> \u2026 season, <b>e</b> \u2026 episode, <b>t</b> \u2026 title</html>
|
episode.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 name, <b>s</b> \u2026 season, <b>e</b> \u2026 episode, <b>t</b> \u2026 title</html>
|
||||||
movie.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 name, <b>y</b> \u2026 year</html>
|
movie.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 name, <b>y</b> \u2026 year</html>
|
||||||
music.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 artist, <b>t</b> \u2026 title, <b>album</b> \u2026 album</html>
|
music.syntax: <html><b>{</b> <b>}</b> \u2026 expression, <b>n</b> \u2026 album artist, <b>t</b> \u2026 title, <b>album</b> \u2026 album, <b>pi</b> \u2026 track</html>
|
||||||
|
|
||||||
episode.sample: Dark Angel - 3x01 - Labyrinth [2009-06-01]
|
episode.sample: {"@type":"net.sourceforge.filebot.web.Episode","seriesName":"Firefly","seriesStartDate":{"year":2002,"month":9,"day":20},"season":1,"episode":1,"title":"Serenity","absolute":1,"special":null,"airdate":{"year":2002,"month":12,"day":20}}
|
||||||
movie.sample: Avatar (2009) Part 1
|
movie.sample: {"@type":"net.sourceforge.filebot.web.MoviePart","partIndex":1,"partCount":2,"year":2009,"imdbId":-1,"tmdbId":19995,"name":"Avatar"}
|
||||||
music.sample: Leona Lewis - I See You
|
music.sample: {"@type":"net.sourceforge.filebot.web.AudioTrack","artist":"Leona Lewis","title":"I See You","album":"Avatar","albumArtist":"James Horner","trackTitle":null,"albumReleaseDate":{"year":2009,"month":12,"day":11},"mediumIndex":1,"mediumCount":1,"trackIndex":14,"trackCount":14}
|
||||||
|
|
||||||
# basic 1.01
|
# basic 1.01
|
||||||
episode.example[0]: {n} - {s}.{e} - {t}
|
episode.example[0]: {n} - {s}.{e} - {t}
|
||||||
|
@ -27,7 +27,7 @@ movie.example[2]: {n} {[y, certification, rating]}
|
||||||
movie.example[3]: {n.space('.')}.{y}{'.'+source}.{vc}
|
movie.example[3]: {n.space('.')}.{y}{'.'+source}.{vc}
|
||||||
|
|
||||||
# simple artist - title
|
# simple artist - title
|
||||||
music.example[0]: {n} - {t}
|
music.example[0]: {artist} - {t}
|
||||||
# simple artist - album - title
|
# simple artist - album - title
|
||||||
music.example[1]: {n} - {album} - {t}
|
music.example[1]: {n} - {album} - {t}
|
||||||
# artist - title [crc32]
|
# artist - title [crc32]
|
||||||
|
|
Loading…
Reference in New Issue