package saccubus;
+import java.io.IOException;
import saccubus.converter.Converter;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import nicobrowser.entity.NicoContent;
+import org.apache.commons.lang.StringUtils;
import saccubus.ConvertStopFlag.State;
import saccubus.converter.profile.FfmpegOption;
import saccubus.converter.profile.NgSetting;
public void DoButton_actionPerformed(ActionEvent e) {
if (Converter == null || Converter.isConverted()) {
- String url;
-
- // NicoBrowser\83t\83@\83C\83\8b\82ð\97\98\97p\82·\82é\8fê\8d\87\82Í\81A\83t\83@\83C\83\8b\96¼\82©\82ç\83r\83f\83IID\82ð\93Á\92è.
- if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
- try {
- String fileName = videoSaveInfoPanel.getNibrFileField().getText();
- NicoDBFinder finder = NicoDBFinder.getInstance();
- NicoContent info = finder.findNicoContent(fileName);
- if (info != null) {
- url = info.getNicoId();
- } else {
- url = "";
- }
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(this, ex.getMessage(), "\83G\83\89\81[", JOptionPane.ERROR_MESSAGE);
- return;
+ try {
+ executeConvert();
+ } catch (Exception ex) {
+ String text = ex.getMessage();
+ if (StringUtils.isEmpty(text)) {
+ text = "\97\\8aú\82µ\82È\82¢\83G\83\89\81[\82Ì\82½\82ß\92\86\92f\82µ\82Ü\82µ\82½\81B";
}
- } else {
- url = VideoID_TextField.getText();
+ statusBar.setText(text);
}
-
- TextProgressListener sl = new TextProgressListener() {
-
- public void setText(final String text) {
- SwingUtilities.invokeLater(new Runnable() {
-
- public void run() {
- statusBar.setText(text);
- }
- });
- }
- };
-
- ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
-
- public void changeState(final State s) {
- SwingUtilities.invokeLater(new Runnable() {
-
- public void run() {
- switch (s) {
- case PROCESSING:
- DoButton.setText(DoButtonStopString);
- break;
- case STOPPING:
- DoButton.setText(DoButtonWaitString);
- break;
- case FINISHED:
- DoButton.setText(DoButtonDefString);
- }
- }
- });
- }
- };
-
- Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
- new ConvertStopFlag(scl));
- new Thread(Converter).start();
} else { /* \8aJ\8en\82µ\82Ä\82¢\82é\82Ì\82Å\81A\83X\83g\83b\83v\82·\82é\81B */
final ConvertStopFlag flag = Converter.getStopFlag();
if (!flag.needStop()) { /* \82Ü\82¾\83X\83g\83b\83v\82µ\82Ä\82¢\82È\82¢\81B */
}
}
+ private void executeConvert() throws IOException {
+ String url;
+
+ // NicoBrowser\83t\83@\83C\83\8b\82ð\97\98\97p\82·\82é\8fê\8d\87\82Í\81A\83t\83@\83C\83\8b\96¼\82©\82ç\83r\83f\83IID\82ð\93Á\92è.
+ if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
+ try {
+ String fileName = videoSaveInfoPanel.getNibrFileField().getText();
+ NicoDBFinder finder = NicoDBFinder.getInstance();
+ NicoContent info = finder.findNicoContent(fileName);
+ if (info != null) {
+ url = info.getNicoId();
+ } else {
+ url = "";
+ }
+ } catch (Exception ex) {
+ JOptionPane.showMessageDialog(this, ex.getMessage(), "\83G\83\89\81[", JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ } else {
+ url = VideoID_TextField.getText();
+ }
+
+ TextProgressListener sl = new TextProgressListener() {
+
+ public void setText(final String text) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ statusBar.setText(text);
+ }
+ });
+ }
+ };
+
+ ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
+
+ public void changeState(final State s) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ switch (s) {
+ case PROCESSING:
+ DoButton.setText(DoButtonStopString);
+ break;
+ case STOPPING:
+ DoButton.setText(DoButtonWaitString);
+ break;
+ case FINISHED:
+ DoButton.setText(DoButtonDefString);
+ }
+ }
+ });
+ }
+ };
+
+ Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
+ new ConvertStopFlag(scl));
+ new Thread(Converter).start();
+
+ }
+
/* FFmpeg\82Ö\82Ì\83p\83X */
public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
showSaveDialog("FFmpeg\82Ö\82Ì\83p\83X", FFmpegPathField, false, false);
this.convertSetting = convertSetting;
}
- public Profile toProfile() {
+ public Profile toProfile() throws IOException {
return new ProfileBuilder().build();
}
private class ProfileBuilder {
- private Profile build() {
+ private Profile build() throws IOException {
LoginInfo loginInfo = buildLoginInfo();
InputFileSetting videoSetting = buildVideoSetting();
InputFileSetting commentSetting = buildCommentSetting();
isAddComment(), setting.isAddTcomment());
}
- private Ffmpeg buildFfmpeg() {
+ private Ffmpeg buildFfmpeg() throws IOException {
final MovieSetting movie = getMovieSetting();
final ConvertSetting conv = getConvertSetting();
try {
fo = FfmpegOption.load(movie.getOptionFile());
} catch (IOException ex) {
- ex.printStackTrace();
+ throw new IOException("\83I\83v\83V\83\87\83\93\83t\83@\83C\83\8b\82Ì\8f\91\8e®\82ª\8cë\82Á\82Ä\82¢\82Ü\82·\81F" + movie.getOptionFile().getName(), ex);
}
}