OSDN Git Service

Cookie関係情報をコンフィグから取得しプロファイルを作成する処理の実装
[coroid/inqubus.git] / frontend / src / saccubus / worker / impl / download / Download.java
index 8a67234..898b7db 100644 (file)
@@ -102,7 +102,7 @@ public class Download extends Worker<DownloadResult, DownloadProgress> {
             final File file = new File(profile.getCommentProfile().getDir(), name);
 
             final EnumSet<DownloadCommentType> commentSet = EnumSet.of(DownloadCommentType.OWNER);
-            if(profile.getCommentProfile().isDisablePerMinComment()) {
+            if (profile.getCommentProfile().isDisablePerMinComment()) {
                 commentSet.add(DownloadCommentType.COMMENT_OLD);
             } else {
                 commentSet.add(DownloadCommentType.COMMENT);
@@ -149,10 +149,15 @@ public class Download extends Worker<DownloadResult, DownloadProgress> {
      */
     private NicoHttpClient createClientAndLogin() throws IOException, InterruptedException {
         final NicoHttpClient client = createClient(profile.getProxyProfile());
+        if (profile.getLoginProfile().needsLogin()) {
 
-        final boolean hasLogin = client.login(profile.getLoginProfile().getMail(), profile.getLoginProfile().getPassword());
-        if (!hasLogin) {
-            throw new IOException("login fail");
+            final boolean hasLogin = client.login(profile.getLoginProfile().getMail(), profile.getLoginProfile().
+                    getPassword());
+            if (!hasLogin) {
+                throw new IOException("login fail");
+            }
+        } else {
+            client.addCookie(profile.getLoginProfile().getCookies());
         }
 
         return client;