mirror of
https://github.com/zoriya/flood.git
synced 2026-06-01 10:35:59 +00:00
Allow setting tags when adding a torrent via URL
This commit is contained in:
@@ -132,6 +132,7 @@ class ClientRequest {
|
||||
addURLsMethodCall(options) {
|
||||
let path = options.path;
|
||||
let start = options.start;
|
||||
let tagsArr = options.tags;
|
||||
let urls = this.getEnsuredArray(options.urls);
|
||||
|
||||
urls.forEach((url) => {
|
||||
@@ -139,10 +140,24 @@ class ClientRequest {
|
||||
let parameters = ['', url];
|
||||
let timeAdded = Math.floor(Date.now() / 1000);
|
||||
|
||||
if (path && path !== '') {
|
||||
if (path) {
|
||||
parameters.push(`d.directory.set="${path}"`);
|
||||
}
|
||||
|
||||
if (tagsArr) {
|
||||
let tags = tagsArr.reduce((memo, currentTag) => {
|
||||
let tag = encodeURIComponent(currentTag.trim());
|
||||
|
||||
if (tag !== '' && memo.indexOf(tag) === -1) {
|
||||
memo.push(tag);
|
||||
}
|
||||
|
||||
return memo;
|
||||
}, []).join(',');
|
||||
|
||||
parameters.push(`d.custom1.set="${tags}"`);
|
||||
}
|
||||
|
||||
parameters.push(`d.custom.set=addtime,${timeAdded}`);
|
||||
|
||||
if (!start) {
|
||||
@@ -162,9 +177,11 @@ class ClientRequest {
|
||||
}
|
||||
|
||||
createDirectoryMethodCall(options) {
|
||||
this.requests.push(
|
||||
this.getMethodCall('execute2', ['mkdir', '-p', options.path])
|
||||
);
|
||||
if (options.path) {
|
||||
this.requests.push(
|
||||
this.getMethodCall('execute2', ['mkdir', '-p', options.path])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fetchSettingsMethodCall(options) {
|
||||
|
||||
@@ -8,7 +8,7 @@ let clientSettingsMap = require('../../shared/constants/clientSettingsMap');
|
||||
let ClientRequest = require('./ClientRequest');
|
||||
let clientUtil = require('../util/clientUtil');
|
||||
let propsMap = require('../../shared/constants/propsMap');
|
||||
let formatUtil = require('../util/formatUtil');
|
||||
let formatUtil = require('../../shared/util/formatUtil');
|
||||
let scgi = require('../util/scgi');
|
||||
let Torrent = require('./Torrent');
|
||||
let TorrentCollection = require('./TorrentCollection');
|
||||
@@ -48,10 +48,11 @@ var client = {
|
||||
let urls = data.urls;
|
||||
let path = data.destination;
|
||||
let start = data.start;
|
||||
let tags = data.tags;
|
||||
let request = new ClientRequest();
|
||||
|
||||
request.add('createDirectory', {path});
|
||||
request.add('addURLs', {urls, path, start});
|
||||
request.add('addURLs', {urls, path, start, tags});
|
||||
request.onComplete(callback);
|
||||
request.send();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user