OSDN Git Service

getWayBackKeyメソッドではwaybackkey取得のみを行うようにインタフェースを定義しなおし
[coroid/inqubus.git] / frontend / src / saccubus / converter / filegetter / WebFileInstanciator.java
index a2cd758..e53a5b9 100644 (file)
@@ -3,10 +3,14 @@ package saccubus.converter.filegetter;
 
 import java.io.IOException;
 import java.text.Normalizer;
+import org.apache.commons.lang.StringUtils;
 import saccubus.ConvertStopFlag;
 import saccubus.converter.profile.Proxy;
+import saccubus.net.CommentInfo;
 import saccubus.net.NicoClient;
+import saccubus.net.NicoClientImpl;
 import saccubus.net.VideoInfo;
+import saccubus.util.WayBackTimeParser;
 
 /**
  * 動画ファイル, コメントファイルなど必要なファイルのうち, 1つでもダウンロード処理を必要とする場合のインスタンス化クラス.
@@ -16,6 +20,7 @@ public class WebFileInstanciator extends FileInstanciator {
 
     private final NicoClient client;
     private final VideoInfo videoInfo;
+    private final CommentInfo commentInfo;
 
     WebFileInstanciator(
             ConvertStopFlag stopFlag,
@@ -40,14 +45,25 @@ public class WebFileInstanciator extends FileInstanciator {
             host = null;
             port = -1;
         }
-        client = new NicoClient(li.getMail(), li.getPass(), stopFlag, host, port);
+        // TODO Implを直接newしている
+        client = new NicoClientImpl(li.getMail(), li.getPass(), stopFlag, host, port) {
+        };
 
         if (!client.isLoggedIn()) {
             throw new IOException("ログインに失敗");
         }
 
         try {
-            videoInfo = client.getVideoInfo(tag, time);
+            videoInfo = client.getVideoInfo(tag);
+            if (StringUtils.isNotBlank(time)) {
+                System.out.print("Setting wayback time...");
+                final String waybacktime = WayBackTimeParser.parse(time);
+                String waybackkey = client.getWayBackKey(videoInfo);
+                commentInfo = new CommentInfo(waybackkey, waybacktime);
+            }else{
+                commentInfo = CommentInfo.DEFAULT;
+            }
+
         } catch (IOException ex) {
             throw new IOException(tag + "の情報の取得に失敗", ex);
         }
@@ -57,7 +73,7 @@ public class WebFileInstanciator extends FileInstanciator {
         }
 
         if (commentType.isDoanload()) {
-            setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentType.isAutoCommentNum(),
+            setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentInfo, commentType.isAutoCommentNum(),
                     commentType.getBackComment()));
         }