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
|
||||
|
||||
## 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
|
||||
|
||||
* [#21349](https://github.com/qbittorrent/qBittorrent/pull/21349)
|
||||
|
|
|
@ -786,6 +786,46 @@ void TorrentsController::filesAction()
|
|||
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.
|
||||
// The return value is a JSON-formatted array of strings (hex strings).
|
||||
void TorrentsController::pieceHashesAction()
|
||||
|
|
|
@ -48,6 +48,7 @@ private slots:
|
|||
void editWebSeedAction();
|
||||
void removeWebSeedsAction();
|
||||
void filesAction();
|
||||
void bulkFilesAction();
|
||||
void pieceHashesAction();
|
||||
void pieceStatesAction();
|
||||
void startAction();
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#include "base/utils/version.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 AuthController;
|
||||
|
|
|
@ -298,7 +298,8 @@
|
|||
path: file.name,
|
||||
original: window.qBittorrent.Filesystem.fileName(file.name),
|
||||
renamed: "",
|
||||
size: file.size
|
||||
size: file.size,
|
||||
torrentHash: file.torrent_hash
|
||||
};
|
||||
|
||||
return row;
|
||||
|
@ -375,7 +376,7 @@
|
|||
};
|
||||
|
||||
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({
|
||||
hash: data.hash
|
||||
});
|
||||
|
|
|
@ -397,7 +397,6 @@ window.qBittorrent.ContextMenu ??= (() => {
|
|||
: this.hideItem("renameFiles");
|
||||
}
|
||||
else {
|
||||
this.hideItem("renameFiles");
|
||||
this.hideItem("rename");
|
||||
}
|
||||
|
||||
|
|
|
@ -740,15 +740,20 @@ const initializeWindows = () => {
|
|||
|
||||
renameFilesFN = () => {
|
||||
const hashes = torrentsTable.selectedRowsIds();
|
||||
if (hashes.length === 1) {
|
||||
const hash = hashes[0];
|
||||
const hashList = hashes.join("|");
|
||||
const rows = [];
|
||||
hashes.forEach((hash) => {
|
||||
const row = torrentsTable.getRow(hash);
|
||||
if (row) {
|
||||
if (row)
|
||||
rows.push(row);
|
||||
});
|
||||
if (rows.length === 0)
|
||||
return;
|
||||
new MochaUI.Window({
|
||||
id: "multiRenamePage",
|
||||
icon: "images/qbittorrent-tray.svg",
|
||||
title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TransferListWidget]",
|
||||
data: { hash: hash, selectedRows: [] },
|
||||
data: { hash: hashList, selectedRows: rows },
|
||||
loadMethod: "xhr",
|
||||
contentURL: "rename_files.html",
|
||||
scrollbars: false,
|
||||
|
@ -760,8 +765,6 @@ const initializeWindows = () => {
|
|||
height: 420,
|
||||
resizeLimit: { x: [800], y: [420] }
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
startVisibleTorrentsFN = () => {
|
||||
|
|
|
@ -244,7 +244,7 @@ window.qBittorrent.MultiRename ??= (() => {
|
|||
await fetch((isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
|
||||
method: "POST",
|
||||
body: new URLSearchParams({
|
||||
hash: this.hash,
|
||||
hash: match.data.torrentHash,
|
||||
oldPath: oldPath,
|
||||
newPath: newPath
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue