mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
WebUI: add optional parameters for /command/download & /command/upload
Specifically: torrent name: string download limit, upload limit: number in bytes, default: -1 (unlimited) sequential download, first last piece prio: boolean true/false, default: false
This commit is contained in:
parent
66b86888fc
commit
f350977cb4
@ -73,9 +73,12 @@ static const char *__TRANSLATIONS__[] = {
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Invalid category name:\nPlease do not use any special characters in the category name."),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Unknown"),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Hard Disk"),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Share ratio limit must be between 0 and 9998.")
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Seeding time limit must be between 0 and 525600 minutes.")
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Set location")
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Share ratio limit must be between 0 and 9998."),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Seeding time limit must be between 0 and 525600 minutes."),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Set location"),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Limit upload rate"),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Limit download rate"),
|
||||
QT_TRANSLATE_NOOP("HttpServer", "Rename torrent")
|
||||
};
|
||||
|
||||
static const struct { const char *source; const char *comment; } __COMMENTED_TRANSLATIONS__[] = {
|
||||
|
@ -414,11 +414,16 @@ void WebApplication::action_command_download()
|
||||
|
||||
const QString urls = request().posts.value("urls");
|
||||
const bool skipChecking = parseBool(request().posts.value("skip_checking"), false);
|
||||
const bool seqDownload = parseBool(request().posts.value("sequentialDownload"), false);
|
||||
const bool firstLastPiece = parseBool(request().posts.value("firstLastPiecePrio"), false);
|
||||
const TriStateBool addPaused = parseTristatebool(request().posts.value("paused"));
|
||||
const TriStateBool rootFolder = parseTristatebool(request().posts.value("root_folder"));
|
||||
const QString savepath = request().posts.value("savepath").trimmed();
|
||||
const QString category = request().posts.value("category").trimmed();
|
||||
const QString cookie = request().posts.value("cookie");
|
||||
const QString torrentName = request().posts.value("rename").trimmed();
|
||||
const int upLimit = request().posts.value("upLimit").toInt();
|
||||
const int dlLimit = request().posts.value("dlLimit").toInt();
|
||||
|
||||
QList<QNetworkCookie> cookies;
|
||||
if (!cookie.isEmpty()) {
|
||||
@ -437,10 +442,15 @@ void WebApplication::action_command_download()
|
||||
BitTorrent::AddTorrentParams params;
|
||||
// TODO: Check if destination actually exists
|
||||
params.skipChecking = skipChecking;
|
||||
params.sequential = seqDownload;
|
||||
params.firstLastPiecePriority = firstLastPiece;
|
||||
params.addPaused = addPaused;
|
||||
params.createSubfolder = rootFolder;
|
||||
params.savePath = savepath;
|
||||
params.category = category;
|
||||
params.name = torrentName;
|
||||
params.uploadLimit = (upLimit > 0) ? upLimit : -1;
|
||||
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
|
||||
|
||||
bool partialSuccess = false;
|
||||
for (QString url : urls.split('\n')) {
|
||||
@ -462,10 +472,15 @@ void WebApplication::action_command_upload()
|
||||
CHECK_URI(0);
|
||||
|
||||
const bool skipChecking = parseBool(request().posts.value("skip_checking"), false);
|
||||
const bool seqDownload = parseBool(request().posts.value("sequentialDownload"), false);
|
||||
const bool firstLastPiece = parseBool(request().posts.value("firstLastPiecePrio"), false);
|
||||
const TriStateBool addPaused = parseTristatebool(request().posts.value("paused"));
|
||||
const TriStateBool rootFolder = parseTristatebool(request().posts.value("root_folder"));
|
||||
const QString savepath = request().posts.value("savepath").trimmed();
|
||||
const QString category = request().posts.value("category").trimmed();
|
||||
const QString torrentName = request().posts.value("rename").trimmed();
|
||||
const int upLimit = request().posts.value("upLimit").toInt();
|
||||
const int dlLimit = request().posts.value("dlLimit").toInt();
|
||||
|
||||
for (const Http::UploadedFile &torrent : request().files) {
|
||||
const QString filePath = saveTmpFile(torrent.data);
|
||||
@ -485,10 +500,15 @@ void WebApplication::action_command_upload()
|
||||
BitTorrent::AddTorrentParams params;
|
||||
// TODO: Check if destination actually exists
|
||||
params.skipChecking = skipChecking;
|
||||
params.sequential = seqDownload;
|
||||
params.firstLastPiecePriority = firstLastPiece;
|
||||
params.addPaused = addPaused;
|
||||
params.createSubfolder = rootFolder;
|
||||
params.savePath = savepath;
|
||||
params.category = category;
|
||||
params.name = torrentName;
|
||||
params.uploadLimit = (upLimit > 0) ? upLimit : -1;
|
||||
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
|
||||
|
||||
if (!BitTorrent::Session::instance()->addTorrent(torrentInfo, params)) {
|
||||
status(500, "Internal Server Error");
|
||||
|
@ -25,6 +25,10 @@
|
||||
<label for="cookie" class="leftLabelLarge">QBT_TR(Cookie:)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" id="cookie" name="cookie" style="width: 16em;"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="rename" class="leftLabelLarge">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" name="rename" style="width: 16em;"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
<input type="text" id="category" name="category" style="width: 16em;"/>
|
||||
@ -42,6 +46,23 @@
|
||||
<label for="root_folder" class="leftLabelLarge">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
<input type="checkbox" name="root_folder" value="true" checked="checked"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="sequentialDownload" class="leftLabelLarge">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label>
|
||||
<input type="checkbox" name="sequentialDownload" value="true"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="firstLastPiecePrio" class="leftLabelLarge">QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]</label>
|
||||
<input type="checkbox" name="firstLastPiecePrio" value="true"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="dlLimit" class="leftLabelLarge">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" name="dlLimit" style="width: 16em;" placeholder="Bytes/s"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="upLimit" class="leftLabelLarge">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" name="upLimit" style="width: 16em;" placeholder="Bytes/s"/>
|
||||
</div>
|
||||
<div id="submitbutton" style="margin-top: 12px; text-align: center;">
|
||||
<button type="submit" id="submitButton">QBT_TR(Download)QBT_TR[CONTEXT=downloadFromURL]</button>
|
||||
</div>
|
||||
|
@ -21,9 +21,13 @@
|
||||
<label for="savepath" class="leftLabelLarge">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" id="savepath" name="savepath" style="width: 16em;"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="rename" class="leftLabelLarge">QBT_TR(Rename torrent)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" name="rename" style="width: 16em;"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
<input type="text" id="category" name="category"/ style="width: 16em;"/>
|
||||
<input type="text" id="category" name="category" style="width: 16em;"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="start_torrent" class="leftLabelLarge">QBT_TR(Start torrent)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
@ -38,6 +42,22 @@
|
||||
<label for="root_folder" class="leftLabelLarge">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
<input type="checkbox" name="root_folder" value="true" checked="checked"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="sequentialDownload" class="leftLabelLarge">QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]</label>
|
||||
<input type="checkbox" name="sequentialDownload" value="true"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="firstLastPiecePrio" class="leftLabelLarge">QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]</label>
|
||||
<input type="checkbox" name="firstLastPiecePrio" value="true"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="dlLimit" class="leftLabelLarge">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" name="dlLimit" style="width: 16em;" placeholder="Bytes/s"/>
|
||||
</div>
|
||||
<div class="formRow">
|
||||
<label for="upLimit" class="leftLabelLarge">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
|
||||
<input type="text" name="upLimit" style="width: 16em;" placeholder="Bytes/s"/>
|
||||
</div>
|
||||
<div id="submitbutton" style="margin-top: 30px; text-align: center;">
|
||||
<button type="submit" style="font-size: 1em;">QBT_TR(Upload Torrents)QBT_TR[CONTEXT=HttpServer]</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user