diff --git a/manifest.json b/manifest.json
index 4cbc43b..d68b305 100644
--- a/manifest.json
+++ b/manifest.json
@@ -34,6 +34,7 @@
"webuiapis/nodejsrtorrentWebUI.js",
"webuiapis/SynologyWebUI.js",
"webuiapis/floodWebUI.js",
+ "webuiapis/flood-jesecWebUI.js",
"webuiapis/tTorrentWebUI.js",
"webuiapis/rtorrentXmlRpc.js"
]
diff --git a/miscapis/config.js b/miscapis/config.js
index bf109d7..cb6bd3a 100644
--- a/miscapis/config.js
+++ b/miscapis/config.js
@@ -6,6 +6,7 @@ RTA.clients.config.getConfig = function(client, name) {
"Deluge WebUI" : RTA.clients.config.deluge,
"Hadouken WebUI" : RTA.clients.config.hadouken,
"flood WebUI" : RTA.clients.config.flood,
+ "flood-jesec WebUI" : RTA.clients.config.floodJesec,
"QNAP DownloadStation" : RTA.clients.config.qnap,
"qBittorrent WebUI" : RTA.clients.config.qbittorrent,
"qBittorrent v4.1+ WebUI" : RTA.clients.config.qbittorrentv2,
@@ -209,6 +210,20 @@ RTA.clients.config.flood = multiline(function(){/*
*/});
+RTA.clients.config.floodJesec = multiline(function(){/*
+
+
+ Directory (optional) |
+
+ Default directory to store added torrents in. This should be an absolute path. It should be inside your default directory for torrents. |
+
+
+ Add torrents paused? |
+ |
+
+
+ */});
+
RTA.clients.config.qnap = multiline(function(){/*
diff --git a/miscapis/functions.js b/miscapis/functions.js
index 9469704..728d5b5 100644
--- a/miscapis/functions.js
+++ b/miscapis/functions.js
@@ -46,6 +46,8 @@ RTA.dispatchTorrent = function(server, data, name, label, dir) {
RTA.clients.synologyAdder(server, data, name); break;
case "flood WebUI":
RTA.clients.floodAdder(server, data, name); break;
+ case "flood-jesec WebUI":
+ RTA.clients.floodJesecAdder(server, data, name); break;
case "QNAP DownloadStation":
RTA.clients.qnapDownloadStationAdder(server, data, name); break;
case "tTorrent WebUI":
@@ -253,3 +255,14 @@ RTA.convertToBlob = function(data, myType="text/plain") {
return dataBlob;
};
+
+
+RTA.blobToBase64 = function(blob) {
+ const reader = new FileReader();
+ reader.readAsDataURL(blob);
+ return new Promise(resolve => {
+ reader.onloadend = () => {
+ resolve(reader.result);
+ };
+ });
+};
\ No newline at end of file
diff --git a/options.html b/options.html
index a306c29..35308c9 100644
--- a/options.html
+++ b/options.html
@@ -38,6 +38,7 @@ Remote Torrent Adder
+
diff --git a/webuiapis/flood-jesecWebUI.js b/webuiapis/flood-jesecWebUI.js
new file mode 100644
index 0000000..b946409
--- /dev/null
+++ b/webuiapis/flood-jesecWebUI.js
@@ -0,0 +1,65 @@
+RTA.clients.floodJesecAdder = function(server, torrentdata) {
+ var dir = server.floodjesecdirectory;
+ var paused = server.floodjesecaddpaused;
+
+ var apiUrl = (server.hostsecure ? "https://" : "http://") + server.host + ":" + server.port;
+
+ fetch(apiUrl + "/api/auth/authenticate", {
+ method: 'POST',
+ headers: {
+ "Content-Type": "application/json; charset=UTF-8"
+ },
+ body: JSON.stringify({"username": server.login, "password": server.password})
+ })
+ .then(RTA.handleFetchError)
+ .then(response => response.json())
+ .then(async function(json) {
+ if(!json.success) {
+ RTA.displayResponse("Failure", "Login to " + server.name + "'s WebUI failed.", true);
+ } else {
+ var fetchOpts = {
+ method: 'POST',
+ headers : { "Content-Type": "application/json; charset=UTF-8" }
+ };
+ if(torrentdata.substring(0,7) == "magnet:") {
+ apiUrl += "/api/torrents/add-urls";
+ fetchOpts.body = JSON.stringify({ "urls": [ torrentdata ], "start": !paused, "destination": (!!dir ? dir : undefined), "isBasePath": false, "isCompleted": false });
+ } else {
+ const dataBlob = RTA.convertToBlob(torrentdata, "application/x-bittorrent");
+
+ apiUrl += "/api/torrents/add-files";
+
+ let b64file = await RTA.blobToBase64(dataBlob);
+ b64file = b64file.substr(b64file.lastIndexOf(',') + 1);
+
+ fetchOpts.body = JSON.stringify({
+ tags: [],
+ "start": !paused,
+ "destination": (!!dir ? dir : undefined),
+ "isBasePath": false,
+ "isCompleted": false,
+ "files": [
+ b64file
+ ]
+ });
+ }
+
+ fetch(apiUrl, fetchOpts)
+ .then(RTA.handleFetchError)
+ .then(response => {
+ if(response.status == 200) {
+ RTA.displayResponse("Success", "Torrent added successfully.");
+ } else {
+ RTA.displayResponse("Failure", "Torrent not added successfully:\n" + text);
+ }
+ })
+ .catch(error => {
+ RTA.displayResponse("Failure", "Could not contact " + server.name + "\nError: " + error.message, true);
+ });
+ }
+ })
+ .catch(error => {
+ RTA.displayResponse("Failure", "Could not contact " + server.name + "\nError: " + error.message, true);
+ });
+
+};