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