|
|
@ -101,11 +101,9 @@ public class QbittorrentAdapter implements IDaemonAdapter { |
|
|
|
} |
|
|
|
} |
|
|
|
catch (DaemonException e) { |
|
|
|
catch (DaemonException e) { |
|
|
|
apiVersion = 1; |
|
|
|
apiVersion = 1; |
|
|
|
log.d(LOG_NAME, e.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (NumberFormatException e) { |
|
|
|
catch (NumberFormatException e) { |
|
|
|
apiVersion = 1; |
|
|
|
apiVersion = 1; |
|
|
|
log.d(LOG_NAME, e.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.d(LOG_NAME, "qBittorrent API version is " + apiVersion); |
|
|
|
log.d(LOG_NAME, "qBittorrent API version is " + apiVersion); |
|
|
@ -162,16 +160,12 @@ public class QbittorrentAdapter implements IDaemonAdapter { |
|
|
|
// Have we already authenticated? Check if we have the cookie that we need
|
|
|
|
// Have we already authenticated? Check if we have the cookie that we need
|
|
|
|
List<Cookie> cookies = httpclient.getCookieStore().getCookies(); |
|
|
|
List<Cookie> cookies = httpclient.getCookieStore().getCookies(); |
|
|
|
for (Cookie c : cookies) { |
|
|
|
for (Cookie c : cookies) { |
|
|
|
log.d(LOG_NAME, "Looking at this cookie: " + c.getName()); |
|
|
|
|
|
|
|
if (c.getName().equals("SID")) { |
|
|
|
if (c.getName().equals("SID")) { |
|
|
|
// And here it is! Okay, no need authenticate again.
|
|
|
|
// And here it is! Okay, no need authenticate again.
|
|
|
|
log.d(LOG_NAME, "We're already authed, no need to do it again."); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.d(LOG_NAME, "Authenticating..."); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
makeRequest(log, "/login", |
|
|
|
makeRequest(log, "/login", |
|
|
|
new BasicNameValuePair("username", settings.getUsername()), |
|
|
|
new BasicNameValuePair("username", settings.getUsername()), |
|
|
|
new BasicNameValuePair("password", settings.getPassword())); |
|
|
|
new BasicNameValuePair("password", settings.getPassword())); |
|
|
@ -180,10 +174,8 @@ public class QbittorrentAdapter implements IDaemonAdapter { |
|
|
|
// However, we would like to see if authentication was successful or not...
|
|
|
|
// However, we would like to see if authentication was successful or not...
|
|
|
|
cookies = httpclient.getCookieStore().getCookies(); |
|
|
|
cookies = httpclient.getCookieStore().getCookies(); |
|
|
|
for (Cookie c : cookies) { |
|
|
|
for (Cookie c : cookies) { |
|
|
|
log.d(LOG_NAME, "post auth looking at this cookie: " + c.getName()); |
|
|
|
|
|
|
|
if (c.getName().equals("SID")) { |
|
|
|
if (c.getName().equals("SID")) { |
|
|
|
// Good. Let's get out of here.
|
|
|
|
// Good. Let's get out of here.
|
|
|
|
log.d(LOG_NAME, "Authentication success!"); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -609,9 +601,9 @@ public class QbittorrentAdapter implements IDaemonAdapter { |
|
|
|
|
|
|
|
|
|
|
|
long size; |
|
|
|
long size; |
|
|
|
if (apiVersion >= 2) { |
|
|
|
if (apiVersion >= 2) { |
|
|
|
size = parseSize(file.getString("size")); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
size = file.getLong("size"); |
|
|
|
size = file.getLong("size"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
size = parseSize(file.getString("size")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
torrentfiles.add(new TorrentFile("" + i, file.getString("name"), null, null, size, (long) (size * file |
|
|
|
torrentfiles.add(new TorrentFile("" + i, file.getString("name"), null, null, size, (long) (size * file |
|
|
|