Compare commits

...

4 Commits

Author SHA1 Message Date
Eric Kok aadddd0d3a
Merge pull request #624 from bwitt/fix-qb-high-priority 2 years ago
Eric Kok b8b26701b1
Merge pull request #621 from bitcometdev/master 2 years ago
Brian Witt 7a12370cbe Fix setting High file priority on qBittorrent 3.2.x+ 2 years ago
wxhere 35e9f4734d Fix torrent status parsing for BitComet. 2 years ago
  1. 16
      app/src/main/java/org/transdroid/daemon/adapters/bitComet/BitCometAdapter.java
  2. 24
      app/src/main/java/org/transdroid/daemon/adapters/qBittorrent/QBittorrentAdapter.java

16
app/src/main/java/org/transdroid/daemon/adapters/bitComet/BitCometAdapter.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
/*
/*
* This file is part of Transdroid <http://www.transdroid.org>
*
* Transdroid is free software: you can redistribute it and/or modify
@ -592,6 +592,12 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -592,6 +592,12 @@ public class BitCometAdapter implements IDaemonAdapter {
// End of a 'transfer' item, add gathered torrent data
sizeDone = (long) (totalSize * progress);
// Fix seeding status for completed torrents
if (status == TorrentStatus.Downloading && progress >= 1) {
status = TorrentStatus.Seeding;
}
// @formatter:off
torrents.add(new Torrent(
id,
@ -656,10 +662,10 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -656,10 +662,10 @@ public class BitCometAdapter implements IDaemonAdapter {
status = convertStatus(xpp.getText());
break;
case "bytes_downloaded":
sizeDone = Integer.parseInt(xpp.getText());
sizeDone = Long.parseLong(xpp.getText());
break;
case "bytes_uploaded":
sizeUp = Integer.parseInt(xpp.getText());
sizeUp = Long.parseLong(xpp.getText());
break;
case "size":
totalSize = Long.parseLong(xpp.getText());
@ -778,6 +784,10 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -778,6 +784,10 @@ public class BitCometAdapter implements IDaemonAdapter {
return TorrentStatus.Paused;
} else if (state.equals("running")) {
return TorrentStatus.Downloading;
} else if (state.equals("hashing")) {
return TorrentStatus.Checking;
} else if (state.equals("queued")) {
return TorrentStatus.Queued;
}
return TorrentStatus.Unknown;
}

24
app/src/main/java/org/transdroid/daemon/adapters/qBittorrent/QBittorrentAdapter.java

@ -90,6 +90,10 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -90,6 +90,10 @@ public class QBittorrentAdapter implements IDaemonAdapter {
private DefaultHttpClient httpclient;
private int version = -1;
private long lastAuthTime = -1;
private int qbNoPriority = 0;
private int qbLowPriority = 1;
private int qbNormalPriority = 2;
private int qbHighPriority = 7;
public QBittorrentAdapter(DaemonSettings settings) {
this.settings = settings;
@ -124,10 +128,14 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -124,10 +128,14 @@ public class QBittorrentAdapter implements IDaemonAdapter {
}
version = parseVersionNumber(versionText);
if (version >= 30200) {
qbNormalPriority = 6;
}
} catch (Exception e) {
// Unable to establish version number; assume an old version by setting it to version 1
version = 10000;
qbNormalPriority = 2;
}
}
@ -371,13 +379,13 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -371,13 +379,13 @@ public class QBittorrentAdapter implements IDaemonAdapter {
// Update the priorities to a set of files
SetFilePriorityTask setPrio = (SetFilePriorityTask) task;
String newPrio = "0";
int newPrio = qbNoPriority;
if (setPrio.getNewPriority() == Priority.Low) {
newPrio = "1";
newPrio = qbLowPriority;
} else if (setPrio.getNewPriority() == Priority.Normal) {
newPrio = "2";
newPrio = qbNormalPriority;
} else if (setPrio.getNewPriority() == Priority.High) {
newPrio = "7";
newPrio = qbHighPriority;
}
// We have to make a separate request per file, it seems
for (TorrentFile file : setPrio.getForFiles()) {
@ -387,7 +395,7 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -387,7 +395,7 @@ public class QBittorrentAdapter implements IDaemonAdapter {
path = "/command/setFilePrio";
}
makeRequest(log, path, new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID()),
new BasicNameValuePair("id", file.getKey()), new BasicNameValuePair("priority", newPrio));
new BasicNameValuePair("id", file.getKey()), new BasicNameValuePair("priority", Integer.toString(newPrio)));
}
return new DaemonTaskSuccessResult(task);
@ -891,11 +899,11 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -891,11 +899,11 @@ public class QBittorrentAdapter implements IDaemonAdapter {
private Priority parsePriority(int priority) {
// Priority is an integer
// Actually 1 = Normal, 2 = High, 7 = Maximum, but adjust this to Transdroid values
if (priority == 0) {
if (priority == qbNoPriority) {
return Priority.Off;
} else if (priority == 1) {
} else if (priority == qbLowPriority) {
return Priority.Low;
} else if (priority == 2) {
} else if (priority == qbNormalPriority) {
return Priority.Normal;
}
return Priority.High;

Loading…
Cancel
Save