1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 16:28:51 -05:00

* better logic for path-separator clean-up for expression bindings

* new ant-task to automatically deploy fatjat/webstart-jars
This commit is contained in:
Reinhard Pointner 2010-02-04 16:22:45 +00:00
parent 193c53273b
commit 911cc24ba5
3 changed files with 58 additions and 7 deletions

View File

@ -2,7 +2,7 @@
<project name="FileBot" default="jar">
<property name="title" value="${ant.project.name}" />
<property name="version" value="1.9" />
<property name="version" value="r420" />
<tstamp>
<format property="today" pattern="yyyy-MM-dd" />
@ -248,5 +248,34 @@
<target name="run-fatjar" depends="fatjar">
<java jar="${dir.dist}/fatjar/FileBot_${version}.jar" fork="true" />
</target>
<target name="deploy">
<!-- ask for sourceforge password -->
<input message="Please enter password:" addproperty="sf.password" />
<!-- create fatjar release folder -->
<mkdir dir="${dir.dist}/release" />
<!-- copy fatjar and source -->
<copy todir="${dir.dist}/release/FileBot_${version}">
<fileset dir="${dir.dist}" includes="*-src.zip" />
<fileset dir="${dir.dist}/fatjar" includes="*.jar" />
</copy>
<!-- deploy source zip first-->
<scp todir="rednoah,filebot:${sf.password}@web.sourceforge.net:/home/frs/project/f/fi/filebot/filebot" trust="yes">
<fileset dir="${dir.dist}/release" includes="**/*-src.zip" />
</scp>
<!-- deploy fatjar afterwards so it will be the latest file release -->
<scp todir="rednoah,filebot:${sf.password}@web.sourceforge.net:/home/frs/project/f/fi/filebot/filebot" trust="yes">
<fileset dir="${dir.dist}/release" includes="**/*.jar"/>
</scp>
<!-- deploy webstart jars -->
<scp todir="rednoah,filebot:${sf.password}@web.sourceforge.net:htdocs/webstart" trust="yes">
<fileset dir="${dir.dist}/webstart" />
</scp>
</target>
</project>

View File

@ -5,7 +5,6 @@ package net.sourceforge.filebot.format;
import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.format.Define.*;
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
import static net.sourceforge.tuned.FileUtilities.*;
import java.io.File;
import java.io.FileInputStream;
@ -48,8 +47,7 @@ public class EpisodeBindingBean {
@Define("n")
public String getSeriesName() {
// clean up series name just in case there are any path separators like / or \
return removePathSeparators(episode.getSeriesName());
return episode.getSeriesName();
}
@ -67,8 +65,7 @@ public class EpisodeBindingBean {
@Define("t")
public String getTitle() {
// clean up episode title just in case there are any path separators like / or \
return removePathSeparators(episode.getTitle());
return episode.getTitle();
}

View File

@ -2,11 +2,15 @@
package net.sourceforge.filebot.ui.panel.rename;
import static net.sourceforge.tuned.FileUtilities.*;
import java.io.File;
import javax.script.Bindings;
import javax.script.ScriptException;
import net.sourceforge.filebot.format.EpisodeBindingBean;
import net.sourceforge.filebot.format.ExpressionBindings;
import net.sourceforge.filebot.format.ExpressionFormat;
import net.sourceforge.filebot.similarity.Match;
import net.sourceforge.filebot.web.Episode;
@ -48,9 +52,30 @@ class EpisodeExpressionFormatter implements MatchFormatter {
// lazy initialize script engine
if (format == null) {
format = new ExpressionFormat(expression);
format = new ExpressionFormat(expression) {
@Override
public Bindings getBindings(Object value) {
return new ExpressionBindings(value) {
@Override
public Object get(Object key) {
Object value = super.get(key);
// if the binding value is a String, remove illegal characters
if (value instanceof CharSequence) {
return removePathSeparators(value.toString()).trim();
}
// if the binding value is an Object, just leave it
return value;
}
};
}
};
}
// evaluate the expression using the given bindings
String result = format.format(new EpisodeBindingBean(episode, mediaFile)).trim();
// if result is empty, check for script exceptions