mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Merge 020a226ad7
into 3cd40cc5a2
This commit is contained in:
commit
65c33f1109
8 changed files with 75 additions and 26 deletions
|
@ -1,5 +1,10 @@
|
||||||
# WebAPI Changelog
|
# WebAPI Changelog
|
||||||
|
|
||||||
|
## 2.11.9
|
||||||
|
|
||||||
|
* [#22863](https://github.com/qbittorrent/qBittorrent/pull/22863)
|
||||||
|
* Introduce `torrents/bulkFiles`, accepts a list of `hash`es separated with `|` (pipe), returns list of files for all selected torrents
|
||||||
|
|
||||||
## 2.11.8
|
## 2.11.8
|
||||||
|
|
||||||
* [#21349](https://github.com/qbittorrent/qBittorrent/pull/21349)
|
* [#21349](https://github.com/qbittorrent/qBittorrent/pull/21349)
|
||||||
|
|
|
@ -786,6 +786,46 @@ void TorrentsController::filesAction()
|
||||||
setResult(fileList);
|
setResult(fileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a list of all the files in the list of torrent in JSON format.
|
||||||
|
// The return value is a JSON-formatted list of dictionaries.
|
||||||
|
// The dictionary keys are:
|
||||||
|
// - "index": File index
|
||||||
|
// - "name": File name
|
||||||
|
// - "size": File size
|
||||||
|
// - "progress": File progress
|
||||||
|
// - "priority": File priority
|
||||||
|
// - "is_seed": Flag indicating if torrent is seeding/complete
|
||||||
|
// - "piece_range": Piece index range, the first number is the starting piece index
|
||||||
|
// and the second number is the ending piece index (inclusive)
|
||||||
|
// - "torrent_hash": The hash of the torrent from which this file originates
|
||||||
|
void TorrentsController::bulkFilesAction()
|
||||||
|
{
|
||||||
|
requireParams({u"hash"_s});
|
||||||
|
|
||||||
|
const auto ids = params()[u"hash"_s].split(u'|', Qt::SkipEmptyParts);
|
||||||
|
QVariantList fileList;
|
||||||
|
for (const QString &id : ids)
|
||||||
|
{
|
||||||
|
const BitTorrent::Torrent *torrent = BitTorrent::Session::instance()->getTorrent(BitTorrent::TorrentID::fromString(id));
|
||||||
|
if (!torrent)
|
||||||
|
continue;
|
||||||
|
if (!torrent->hasMetadata())
|
||||||
|
continue; // skip torrents without metadata
|
||||||
|
|
||||||
|
auto currentFileList = getFiles(torrent);
|
||||||
|
// Add torrent ID to each file
|
||||||
|
for (QJsonValueRef file : currentFileList)
|
||||||
|
{
|
||||||
|
QJsonObject fileObj = file.toObject();
|
||||||
|
fileObj[u"torrent_hash"] = torrent->id().toString();
|
||||||
|
file = fileObj;
|
||||||
|
}
|
||||||
|
fileList.append(currentFileList.toVariantList());
|
||||||
|
}
|
||||||
|
|
||||||
|
setResult(QJsonArray::fromVariantList(fileList));
|
||||||
|
}
|
||||||
|
|
||||||
// Returns an array of hashes (of each pieces respectively) for a torrent in JSON format.
|
// Returns an array of hashes (of each pieces respectively) for a torrent in JSON format.
|
||||||
// The return value is a JSON-formatted array of strings (hex strings).
|
// The return value is a JSON-formatted array of strings (hex strings).
|
||||||
void TorrentsController::pieceHashesAction()
|
void TorrentsController::pieceHashesAction()
|
||||||
|
|
|
@ -48,6 +48,7 @@ private slots:
|
||||||
void editWebSeedAction();
|
void editWebSeedAction();
|
||||||
void removeWebSeedsAction();
|
void removeWebSeedsAction();
|
||||||
void filesAction();
|
void filesAction();
|
||||||
|
void bulkFilesAction();
|
||||||
void pieceHashesAction();
|
void pieceHashesAction();
|
||||||
void pieceStatesAction();
|
void pieceStatesAction();
|
||||||
void startAction();
|
void startAction();
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
#include "base/utils/version.h"
|
#include "base/utils/version.h"
|
||||||
#include "api/isessionmanager.h"
|
#include "api/isessionmanager.h"
|
||||||
|
|
||||||
inline const Utils::Version<3, 2> API_VERSION {2, 11, 8};
|
inline const Utils::Version<3, 2> API_VERSION {2, 11, 9};
|
||||||
|
|
||||||
class APIController;
|
class APIController;
|
||||||
class AuthController;
|
class AuthController;
|
||||||
|
|
|
@ -298,7 +298,8 @@
|
||||||
path: file.name,
|
path: file.name,
|
||||||
original: window.qBittorrent.Filesystem.fileName(file.name),
|
original: window.qBittorrent.Filesystem.fileName(file.name),
|
||||||
renamed: "",
|
renamed: "",
|
||||||
size: file.size
|
size: file.size,
|
||||||
|
torrentHash: file.torrent_hash
|
||||||
};
|
};
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
@ -375,7 +376,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const setupTable = (selectedRows) => {
|
const setupTable = (selectedRows) => {
|
||||||
const url = new URL("api/v2/torrents/files", window.location);
|
const url = new URL("api/v2/torrents/bulkFiles", window.location);
|
||||||
url.search = new URLSearchParams({
|
url.search = new URLSearchParams({
|
||||||
hash: data.hash
|
hash: data.hash
|
||||||
});
|
});
|
||||||
|
|
|
@ -397,7 +397,6 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||||
: this.hideItem("renameFiles");
|
: this.hideItem("renameFiles");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.hideItem("renameFiles");
|
|
||||||
this.hideItem("rename");
|
this.hideItem("rename");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -740,28 +740,31 @@ const initializeWindows = () => {
|
||||||
|
|
||||||
renameFilesFN = () => {
|
renameFilesFN = () => {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
if (hashes.length === 1) {
|
const hashList = hashes.join("|");
|
||||||
const hash = hashes[0];
|
const rows = [];
|
||||||
|
hashes.forEach((hash) => {
|
||||||
const row = torrentsTable.getRow(hash);
|
const row = torrentsTable.getRow(hash);
|
||||||
if (row) {
|
if (row)
|
||||||
new MochaUI.Window({
|
rows.push(row);
|
||||||
id: "multiRenamePage",
|
});
|
||||||
icon: "images/qbittorrent-tray.svg",
|
if (rows.length === 0)
|
||||||
title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TransferListWidget]",
|
return;
|
||||||
data: { hash: hash, selectedRows: [] },
|
new MochaUI.Window({
|
||||||
loadMethod: "xhr",
|
id: "multiRenamePage",
|
||||||
contentURL: "rename_files.html",
|
icon: "images/qbittorrent-tray.svg",
|
||||||
scrollbars: false,
|
title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TransferListWidget]",
|
||||||
resizable: true,
|
data: { hash: hashList, selectedRows: rows },
|
||||||
maximizable: false,
|
loadMethod: "xhr",
|
||||||
paddingVertical: 0,
|
contentURL: "rename_files.html",
|
||||||
paddingHorizontal: 0,
|
scrollbars: false,
|
||||||
width: 800,
|
resizable: true,
|
||||||
height: 420,
|
maximizable: false,
|
||||||
resizeLimit: { x: [800], y: [420] }
|
paddingVertical: 0,
|
||||||
});
|
paddingHorizontal: 0,
|
||||||
}
|
width: 800,
|
||||||
}
|
height: 420,
|
||||||
|
resizeLimit: { x: [800], y: [420] }
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
startVisibleTorrentsFN = () => {
|
startVisibleTorrentsFN = () => {
|
||||||
|
|
|
@ -244,7 +244,7 @@ window.qBittorrent.MultiRename ??= (() => {
|
||||||
await fetch((isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
|
await fetch((isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
hash: this.hash,
|
hash: match.data.torrentHash,
|
||||||
oldPath: oldPath,
|
oldPath: oldPath,
|
||||||
newPath: newPath
|
newPath: newPath
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue