X-Git-Url: http://git.sourceforge.jp/view?p=coroid%2Finqubus.git;a=blobdiff_plain;f=frontend%2Fsrc%2Fsaccubus%2Fconverter%2FConverter.java;h=84c934fff98ab303ee053e9ae8449e9604acf2c7;hp=e619fd57e38acb098e7ad1dbdd1f94087586d3ac;hb=db2e02c3279ccee6154dc5f465a683aab609a1ad;hpb=c9bedc24eda5d1dde65ec125266d61a6f7ba0ab6
diff --git a/frontend/src/saccubus/converter/Converter.java b/frontend/src/saccubus/converter/Converter.java
index e619fd5..84c934f 100644
--- a/frontend/src/saccubus/converter/Converter.java
+++ b/frontend/src/saccubus/converter/Converter.java
@@ -1,13 +1,15 @@
package saccubus.converter;
-import saccubus.converter.profile.Profile;
-import saccubus.converter.profile.FfmpegOption;
-import saccubus.converter.filegetter.FileInstanciator;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.Callable;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import saccubus.ConvertStopFlag;
+import saccubus.converter.filegetter.FileInstanciator;
import saccubus.net.TextProgressListener;
+import yukihane.saccubus.converter.profile.FfmpegOption;
+import yukihane.saccubus.converter.profile.Profile;
/**
*
ã¿ã¤ãã«: ããã
ã°ã
@@ -21,39 +23,38 @@ import saccubus.net.TextProgressListener;
* @author æªå
¥å
* @version 1.0
*/
-public class Converter extends AbstractCommand implements Runnable, Callable {
+public class Converter extends AbstractCommand implements Callable {
- private static final String VIDEO_URL_PARSER = "http://www.nicovideo.jp/watch/";
- private final Profile Setting;
- private final String Tag;
- private final String Time;
+ private final Profile profile;
+ private final String movieId;
/**
* ã³ã³ãã¼ã¿ãæ§ç¯ãã¾ã.
* @param url 対象ã¨ãªãåç»ã®URL.
* @param time
- * @param setting
+ * @param profile
* @param listener
- * @param flag
+ * @param flag
*/
- public Converter(String url, String time, Profile setting,
+ public Converter(String url, Profile profile,
TextProgressListener listener, ConvertStopFlag flag) {
super(listener, flag);
- url = url.trim();
- if (url.startsWith(VIDEO_URL_PARSER)) {
- int index = url.indexOf('?', VIDEO_URL_PARSER.length());
- if (index >= 0) {
- Tag = url.substring(VIDEO_URL_PARSER.length(), index);
- } else {
- Tag = url.substring(VIDEO_URL_PARSER.length());
- }
+
+ // TODO å
¥åæ¬ã®å¤ããåç»IDã®åãåºãã¯GUIå´ã§ããã¹ãã ãã
+ final int startIdIdx = url.lastIndexOf("/") + 1;
+ final String altId = url.substring(startIdIdx);
+ final Pattern idPattern = Pattern.compile("([a-z]*\\d+)");
+ final Matcher idMatcher = idPattern.matcher(altId);
+ if (idMatcher.find()) {
+ this.movieId = idMatcher.group(1);
} else {
- Tag = url;
+ throw new IllegalArgumentException("URL/IDã®æå®ãä¸æ£ã§ã: " + url);
}
- Time = time;
- Setting = setting;
+
+ this.profile = profile;
}
+ @Override
public Boolean call() throws Exception {
boolean result = false;
try {
@@ -64,6 +65,7 @@ public class Converter extends AbstractCommand implements Runnable, Callable= 0) {
+ if (profile.getFfmpeg().getVhook().getPath().indexOf(' ') >= 0) {
throw new IllegalArgumentException("ããã¾ãããç¾å¨vhookã©ã¤ãã©ãªã«ã¯åè§ç©ºç½ã¯ä½¿ãã¾ããã");
}
- a = Setting.getFfmpeg().getVhook();
+ a = profile.getFfmpeg().getVhook();
if (!a.canRead()) {
throw new IllegalArgumentException("Vhookã©ã¤ãã©ãªãè¦ã¤ããã¾ããã");
}
- a = Setting.getFfmpeg().getFont();
+ a = profile.getFfmpeg().getFont();
if (!a.canRead()) {
throw new IllegalArgumentException("ãã©ã³ããè¦ã¤ããã¾ããã");
}
- } else {
- if (Setting.getVideoSetting().isDelete()) {
- throw new IllegalArgumentException("å¤æããªãã®ã«ãåç»åé¤ãã¡ãã£ã¦è¯ããã§ããï¼");
- }
- if (Setting.getCommentSetting().isDelete()) {
- throw new IllegalArgumentException("å¤æããªãã®ã«ãã³ã¡ã³ãåé¤ãã¡ãã£ã¦è¯ããã§ããï¼");
- }
- if (Setting.getTcommentSetting().isDelete()) {
- throw new IllegalArgumentException("å¤æããªãã®ã«ãæ稿è
ã³ã¡ã³ãåé¤ãã¡ãã£ã¦è¯ããã§ããï¼");
- }
}
}
private String getVideoIDWithBracket() {
- return "[" + Tag + "]";
+ return "[" + movieId + "]";
}
public boolean isConverted() {
@@ -221,4 +203,14 @@ public class Converter extends AbstractCommand implements Runnable, Callable