+++ /dev/null
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package saccubus.worker;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import javax.swing.GroupLayout;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-import saccubus.worker.profile.CommentProfile;
-import saccubus.worker.profile.ConvertProfile;
-import saccubus.worker.profile.FfmpegProfile;
-import saccubus.worker.profile.GeneralProfile;
-import saccubus.worker.profile.LoginProfile;
-import saccubus.worker.profile.OutputProfile;
-import saccubus.worker.profile.DownloadProfile;
-import saccubus.worker.profile.ProxyProfile;
-import saccubus.worker.profile.VideoProfile;
-
-/**
- *
- * @author yuki
- */
-public class TestFrame extends JFrame {
-
- private static final long serialVersionUID = 1L;
- private final JTextField fldVideoId = new JTextField();
- private final JButton btnDownload = new JButton("DOWNLOAD");
- private final JButton btnCancel = new JButton("Cancel");
- private final JTextField fldStatus = new JTextField();
- private final JButton btnConv = new JButton("Conv");
- private final JButton btnConvCancel = new JButton("ConvCancl");
- private Download downloader;
- private Convert converter;
-
- public TestFrame() {
- JPanel panel = new JPanel();
- GroupLayout lo = new GroupLayout(panel);
- panel.setLayout(lo);
-
- lo.setHorizontalGroup(lo.createParallelGroup()
- .addGroup(lo.createSequentialGroup()
- .addComponent(fldVideoId).addComponent(btnDownload))
- .addGroup(lo.createSequentialGroup()
- .addComponent(fldStatus).addComponent(btnCancel))
- .addGroup(lo.createSequentialGroup()
- .addComponent(btnConv).addComponent(btnConvCancel)));
-
- lo.setVerticalGroup(lo.createSequentialGroup()
- .addGroup(lo.createParallelGroup()
- .addComponent(fldVideoId).addComponent(btnDownload))
- .addGroup(lo.createParallelGroup()
- .addComponent(fldStatus).addComponent(btnCancel))
- .addGroup(lo.createParallelGroup()
- .addComponent(btnConv).addComponent(btnConvCancel)));
-
- setContentPane(panel);
- pack();
-
-
- btnDownload.addActionListener(new DownloadListener());
- btnCancel.addActionListener(new CancelListener());
- btnConv.addActionListener(new ConvertListener());
- btnConvCancel.addActionListener(new ConvCnclListener());
- }
-
- private class ConvCnclListener implements ActionListener {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (converter != null) {
- converter.cancel(true);
- }
- }
- }
-
- private class ConvertListener implements ActionListener {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- converter = new Convert(new MyConvProfile(), new File("out/sm8994079.mp4"), new File("out/sm9.xml")) {
-
- @Override
- protected void process(List<ConvertProgress> chunks) {
- ConvertProgress chunk = chunks.get(chunks.size() - 1);
- fldStatus.setText(chunk.getMessage());
- }
-
- @Override
- protected void done() {
- btnConv.setEnabled(true);
- try {
- ConvertResult res = get();
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- } catch (ExecutionException ex) {
- ex.printStackTrace();
- }
- }
- };
-
- btnConv.setEnabled(false);
- converter.execute();
-
- }
- }
-
- private class CancelListener implements ActionListener {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (downloader != null) {
- downloader.cancel(true);
- }
- }
- }
-
- private class DownloadListener implements ActionListener {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- downloader = new Download(new MyProfile(), fldVideoId.getText()) {
-
- @Override
- protected void process(List<DownloadProgress> chunks) {
- DownloadProgress chunk = chunks.get(chunks.size() - 1);
- fldStatus.setText(chunk.getMessage());
- }
-
- @Override
- protected void done() {
- btnDownload.setEnabled(true);
- try {
- DownloadResult res = get();
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- } catch (ExecutionException ex) {
- ex.printStackTrace();
- }
- }
- };
-
- btnDownload.setEnabled(false);
- downloader.execute();
-
- }
- }
-
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- TestFrame view = new TestFrame();
- view.setDefaultCloseOperation(EXIT_ON_CLOSE);
- view.setVisible(true);
- }
- });
- }
-
- private static class MyProfile implements DownloadProfile {
-
- @Override
- public LoginProfile getLoginInfo() {
- return new LoginProfile() {
-
- @Override
- public String getMail() {
- return "yamamoto5_5963@hotmail.com";
- }
-
- @Override
- public String getPassword() {
- return "piyopiyo";
- }
- };
- }
-
- @Override
- public ProxyProfile getProxyProfile() {
- return new ProxyProfile() {
-
- @Override
- public boolean use() {
- return false;
- }
-
- @Override
- public String getHost() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getPort() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- };
- }
-
- @Override
- public VideoProfile getVideoProfile() {
- return new VideoProfile() {
-
- @Override
- public boolean isDownload() {
- return true;
- }
-
- @Override
- public File getDir() {
- return new File("out");
- }
-
- @Override
- public String getFileName() {
- return "{id}";
- }
-
- @Override
- public File getLocalFile() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- };
- }
-
- @Override
- public CommentProfile getCommentProfile() {
- return new CommentProfile() {
-
- @Override
- public int getLengthRelatedCommentSize() {
- return -1;
- }
-
- @Override
- public boolean isDisablePerMinComment() {
- return false;
- }
-
- @Override
- public int getPerMinCommentSize() {
- return -1;
- }
-
- @Override
- public long getBackLogPoint() {
- return -1;
- }
-
- @Override
- public boolean isDownload() {
- return true;
- }
-
- @Override
- public File getDir() {
- return new File("out");
- }
-
- @Override
- public String getFileName() {
- return "{id}_{title}";
- }
-
- @Override
- public File getLocalFile() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- };
- }
-
-// @Override
-// public OutputProfile getOutputFileSetting() {
-// return new OutputProfile() {
-//
-// @Override
-// public boolean isConvert() {
-// return false;
-// }
-//
-// @Override
-// public boolean isAddComment() {
-// throw new UnsupportedOperationException("Not supported yet.");
-// }
-//
-// @Override
-// public File getDir() {
-// throw new UnsupportedOperationException("Not supported yet.");
-// }
-//
-// @Override
-// public String getFileName() {
-// throw new UnsupportedOperationException("Not supported yet.");
-// }
-// };
-// }
- @Override
- public GeneralProfile getGeneralProfile() {
- return new GeneralProfile() {
-
- @Override
- public String getReplaceFrom() {
- return "<>\\/#";
- }
-
- @Override
- public String getReplaceTo() {
- return "_";
- }
- };
- }
- }
-
- private class MyConvProfile implements ConvertProfile {
-
- @Override
- public FfmpegProfile getFfmpegOption() {
- return new FfmpegProfile() {
-
- @Override
- public String getExtOption() {
- return "";
- }
-
- @Override
- public String getInOption() {
- return "";
- }
-
- @Override
- public String getMainOption() {
- return "";
- }
-
- @Override
- public String getOutOption() {
- return "-f ipod -g 150 -qcomp 0.7 -qmin 20 -qmax 30 -qdiff 4 -subq 6 -me_range 16 -i_qfactor 0.714286";
- }
-
- @Override
- public String getAvfilterOption() {
- return "";
- }
-
- @Override
- public boolean isResize() {
- return false;
- }
-
- @Override
- public int getResizeWidth() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getResizeHeight() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isAdjustRatio() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- };
- }
-
- @Override
- public File getFfmpeg() {
- return new File("bin/ffmpeg.exe");
- }
-
- @Override
- public boolean isVhookDisabled() {
- return true;
- }
-
- @Override
- public File getVhook() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public File getTempDir() {
- return new File("out");
- }
-
- @Override
- public File getFont() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getFontIndex() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isCommentOpaque() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isDisableFontSizeArrange() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getShadowIndex() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public boolean isShowConverting() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public int getMaxNumOfComment() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public HideCondition getNgSetting() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public OutputProfile getOutputProfile() {
- return new OutputProfile() {
-
- @Override
- public File getDir() {
- return new File("out");
- }
-
- @Override
- public String getFileName() {
- return "outconv";
- }
-
- @Override
- public String getVideoId() {
- return "";
- }
-
- @Override
- public String getTitile() {
- return "";
- }
- };
- }
-
- @Override
- public GeneralProfile getGeneralProfile() {
- return new GeneralProfile() {
-
- @Override
- public String getReplaceFrom() {
- return "";
- }
-
- @Override
- public String getReplaceTo() {
- return "";
- }
- };
- }
-
- @Override
- public boolean isConvert() {
- return true;
- }
-
- @Override
- public boolean isCommentOverlay() {
- return false;
- }
- }
-}