OSDN Git Service

インタフェースを再考
authoryukihane <yukihane.feather@gmail.com>
Wed, 10 Aug 2011 06:52:43 +0000 (15:52 +0900)
committeryukihane <yukihane.feather@gmail.com>
Thu, 11 Aug 2011 07:06:34 +0000 (16:06 +0900)
(cherry picked from commit 4ad30f6629e0745521aa6307f2d2e17732a5b302)

frontend/src/saccubus/converter/filegetter/CommentFileWebGetter.java
frontend/src/saccubus/net/NicoClient.java
frontend/src/saccubus/net/NicoClientImpl.java

index 0c3c6d0..11ee32b 100644 (file)
@@ -29,7 +29,7 @@ public class CommentFileWebGetter extends TcommFileWebGetter {
     public File get(File file, TextProgressListener listener) throws IOException {
         String com = Integer.toString(backComment);
         if (this.autoCommentNum) {
-            com = getClient().getBackCommentFromLength(getVideoInfo(), com);
+            com = getBackCommentFromLength(getVideoInfo(), com);
         }
 
         File res = getClient().getComment(getVideoInfo(), file, listener, com);
@@ -38,4 +38,19 @@ public class CommentFileWebGetter extends TcommFileWebGetter {
         }
         return res;
     }
+
+    private String getBackCommentFromLength(VideoInfo vi, String def) {
+        final int videoLength  = vi.getVideoLength();
+               if (videoLength < 0) {
+                       return def;
+               } else if (videoLength >= 0 && videoLength < 60) {
+                       return "100";
+               } else if (videoLength >= 60 && videoLength < 300) {
+                       return "250";
+               } else if (videoLength >= 300 && videoLength < 600) {
+                       return "500";
+               } else {
+                       return "1000";
+               }
+    }
 }
index f411ac1..b37a893 100644 (file)
@@ -4,21 +4,20 @@ import java.io.File;
 import java.io.IOException;
 
 /**
- *
+ * いんきゅばすがニコニコ動画にアクセスするためのクラスが実装すべきインタフェース.
+ * ログイン処理はコンストラクタ内で実行しておき、各メソッドは同一セッションで実行される必要があります.
  * @author yuki
  */
 public interface NicoClient {
 
-    String getBackCommentFromLength(VideoInfo videoInfo, String com);
-
-    File getComment(VideoInfo videoInfo, File file, TextProgressListener listener, String com);
+    /** @return ログインが正常に完了していればtrue. */
+    boolean isLoggedIn();
 
-    File getTcomment(VideoInfo videoInfo, File file, TextProgressListener listener);
+    VideoInfo getVideoInfo(String videoId, String time) throws IOException;
 
     File getVideo(VideoInfo videoInfo, File file, TextProgressListener listener);
 
-    boolean isLoggedIn();
-
-    VideoInfo getVideoInfo(String tag, String time) throws IOException;
+    File getComment(VideoInfo videoInfo, File file, TextProgressListener listener, String com);
 
+    File getTcomment(VideoInfo videoInfo, File file, TextProgressListener listener);
 }
index 5928376..03d6590 100644 (file)
@@ -80,22 +80,6 @@ public class NicoClientImpl implements NicoClient {
        }
 
     @Override
-       public String getBackCommentFromLength(VideoInfo vi, String def) {
-        final int videoLength  = vi.getVideoLength();
-               if (videoLength < 0) {
-                       return def;
-               } else if (videoLength >= 0 && videoLength < 60) {
-                       return "100";
-               } else if (videoLength >= 60 && videoLength < 300) {
-                       return "250";
-               } else if (videoLength >= 300 && videoLength < 600) {
-                       return "500";
-               } else {
-                       return "1000";
-               }
-       }
-
-    @Override
     public File getComment(VideoInfo vi, final File file, final TextProgressListener status, String back_comment) {
         return downloadComment(back_comment, file, vi, status, false);
     }