import saccubus.util.FileDropTarget;
import saccubus.util.PopupRightClick;
import saccubus.util.WayBackTimeParser;
+import yukihane.Util;
import yukihane.nicovideo.NicoDBFinder;
/**
if (info != null) {
url = info.getNicoId();
} else {
+ // TODO これはダメ…だけどそのうちこの処理自体削除になる
url = "";
}
} catch (Exception ex) {
}
};
- Converter = new Converter(url, getSetting().toProfile(), sl,
+ final String id = Util.getVideoId(url);
+ Converter = new Converter(id, getSetting().toProfile(), sl,
new ConvertStopFlag(scl));
doButton.setText(DoButtonStopString);
FutureTask<Boolean> task = new FutureTask<Boolean>(Converter);
/**
* コンバータを構築します.
- * @param url 対象となる動画のURL.
+ * @param id 対象となる動画のID.
* @param time
* @param profile
* @param listener
* @param flag
*/
- public Converter(String url, Profile profile,
+ public Converter(String id, Profile profile,
TextProgressListener listener, ConvertStopFlag flag) {
super(listener, flag);
-
- // 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 {
- throw new IllegalArgumentException("URL/IDの指定が不正です: " + url);
- }
-
+ this.movieId = id;
this.profile = profile;
}
throw new IOException(e);
}
- Converter conv = new Converter("dummy", profile, tpl, new ConvertStopFlag(scl));
+ Converter conv = new Converter("dummy0", profile, tpl, new ConvertStopFlag(scl));
ExecutorService es = Executors.newSingleThreadExecutor();
Future<Boolean> future = es.submit((Callable<Boolean>) conv);
try {
/* $Id$ */
package yukihane;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* nicobrowser.util.Utilより, 必要なものをピックアップしたクラス.
+ * その後増えました.
* @author yuki
*/
-public class Util {
+public final class Util {
+
+ private Util() {
+ }
/**
* Content-Type から拡張子を決定する.
}
return contentType.split("/")[1];
}
+
+ public static String getVideoId(final String alterId) {
+ final int startIdIdx = alterId.lastIndexOf("/") + 1;
+ final String altId = alterId.substring(startIdIdx);
+ final Pattern idPattern = Pattern.compile("([a-z]*\\d+)");
+ final Matcher idMatcher = idPattern.matcher(altId);
+ if (!idMatcher.find()) {
+ throw new IllegalArgumentException("URL/IDの指定が不正です: " + alterId);
+ }
+
+ return idMatcher.group(1);
+ }
}