mirror of
https://github.com/zoriya/flood.git
synced 2026-06-02 02:56:05 +00:00
Allow setting tags when adding torrents
This commit is contained in:
@@ -31,6 +31,24 @@ class ClientRequest {
|
||||
}
|
||||
}
|
||||
|
||||
addTagsToRequest(tagsArr, requestParameters) {
|
||||
if (tagsArr && tagsArr.length) {
|
||||
const tags = tagsArr.reduce((accumulator, currentTag) => {
|
||||
const tag = encodeURIComponent(currentTag.trim());
|
||||
|
||||
if (tag !== '' && accumulator.indexOf(tag) === -1) {
|
||||
accumulator.push(tag);
|
||||
}
|
||||
|
||||
return accumulator;
|
||||
}, []).join(',');
|
||||
|
||||
requestParameters.push(`d.custom1.set="${tags}"`);
|
||||
}
|
||||
|
||||
return requestParameters;
|
||||
}
|
||||
|
||||
clearRequestQueue() {
|
||||
this.requests = [];
|
||||
}
|
||||
@@ -97,6 +115,7 @@ class ClientRequest {
|
||||
let files = this.getEnsuredArray(options.files);
|
||||
let path = options.path;
|
||||
let start = options.start;
|
||||
let tagsArr = options.tags;
|
||||
|
||||
files.forEach((file) => {
|
||||
let methodCall = 'load.raw_start';
|
||||
@@ -107,6 +126,8 @@ class ClientRequest {
|
||||
parameters.push(`d.directory.set="${path}"`);
|
||||
}
|
||||
|
||||
parameters = this.addTagsToRequest(tagsArr, parameters);
|
||||
|
||||
parameters.push(`d.custom.set=x-filename,${file.originalname}`);
|
||||
parameters.push(`d.custom.set=addtime,${timeAdded}`);
|
||||
|
||||
@@ -135,19 +156,7 @@ class ClientRequest {
|
||||
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 = this.addTagsToRequest(tagsArr, parameters);
|
||||
|
||||
parameters.push(`d.custom.set=addtime,${timeAdded}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user