Browse Source

Fixed resume and pause in qBittorrent

pull/523/head
Firdaus Ahmad 5 years ago
parent
commit
d1facac2c1
  1. 24
      app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

24
app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

@ -223,7 +223,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
} else if (version >= 30200) { } else if (version >= 30200) {
path = "/query/torrents"; path = "/query/torrents";
} else if (version >= 30000) { } else if (version >= 30000) {
path = "/json/torrents";; path = "/json/torrents";
} else { } else {
path = "/json/events"; path = "/json/events";
} }
@ -327,29 +327,34 @@ public class QbittorrentAdapter implements IDaemonAdapter {
case Pause: case Pause:
// Pause a torrent // Pause a torrent
makeRequest(log, "/command/pause", new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID())); if (version >= 40200) {
makeRequest(log, "/api/v2/torrents/pause", new BasicNameValuePair("hashes", task.getTargetTorrent().getUniqueID()));
} else {
makeRequest(log, "/command/pause", new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID()));
}
return new DaemonTaskSuccessResult(task); return new DaemonTaskSuccessResult(task);
case PauseAll: case PauseAll:
// Resume all torrents // Resume all torrents
if (version >= 40200) { if (version >= 40200) {
path = "/api/v2/torrents/pause"; makeRequest(log, "/api/v2/torrents/pause", new BasicNameValuePair("hashes", "all"));
} else { } else {
path = "/command/pauseall"; makeRequest(log, "/command/pauseall");
} }
makeRequest(log, path);
return new DaemonTaskSuccessResult(task); return new DaemonTaskSuccessResult(task);
case Resume: case Resume:
// Resume a torrent // Resume a torrent
if (version >= 40200) { if (version >= 40200) {
path = "/api/v2/torrents/resume"; makeRequest(log, "/api/v2/torrents/resume", new BasicNameValuePair("hashes", task.getTargetTorrent().getUniqueID()));
} else { } else {
path = "/command/resume"; makeRequest(log, "/command/resume", new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID()));
} }
makeRequest(log, path, new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID()));
return new DaemonTaskSuccessResult(task); return new DaemonTaskSuccessResult(task);
case ResumeAll: case ResumeAll:
@ -357,7 +362,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Resume all torrents // Resume all torrents
if (version >= 40200) { if (version >= 40200) {
path = "/api/v2/torrents/resume"; path = "/api/v2/torrents/resume";
makeRequest(log, path, new BasicNameValuePair("hash", "all")); makeRequest(log, path, new BasicNameValuePair("hashes", "all"));
} else { } else {
makeRequest(log, "/command/resumeall"); makeRequest(log, "/command/resumeall");
} }
@ -527,7 +532,6 @@ public class QbittorrentAdapter implements IDaemonAdapter {
} }
private String makeUploadRequest(String path, String file, Log log) throws DaemonException { private String makeUploadRequest(String path, String file, Log log) throws DaemonException {
try { try {

Loading…
Cancel
Save