mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
server: qBittorrent: use POST method for API calls
Bug: #589, #592 Ref: qbittorrent/qBittorrent#17548, qbittorrent/qBittorrent#17549, qbittorrent/qBittorrent#17563
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import {URLSearchParams} from 'url';
|
||||
|
||||
import axios from 'axios';
|
||||
import FormData from 'form-data';
|
||||
import {URLSearchParams} from 'url';
|
||||
|
||||
import type {QBittorrentConnectionSettings} from '@shared/schema/ClientConnectionSettings';
|
||||
|
||||
@@ -103,7 +102,7 @@ class ClientRequestManager {
|
||||
|
||||
async getAppPreferences(): Promise<QBittorrentAppPreferences> {
|
||||
return axios
|
||||
.get<QBittorrentAppPreferences>(`${this.apiBase}/app/preferences`, {
|
||||
.post<QBittorrentAppPreferences>(`${this.apiBase}/app/preferences`, null, {
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
.then((res) => res.data);
|
||||
@@ -121,7 +120,7 @@ class ClientRequestManager {
|
||||
|
||||
async getTorrentInfos(): Promise<QBittorrentTorrentInfos> {
|
||||
return axios
|
||||
.get<QBittorrentTorrentInfos>(`${this.apiBase}/torrents/info`, {
|
||||
.post<QBittorrentTorrentInfos>(`${this.apiBase}/torrents/info`, null, {
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
.then((res) => res.data);
|
||||
@@ -129,40 +128,49 @@ class ClientRequestManager {
|
||||
|
||||
async getTorrentContents(hash: string): Promise<QBittorrentTorrentContents> {
|
||||
return axios
|
||||
.get<QBittorrentTorrentContents>(`${this.apiBase}/torrents/files`, {
|
||||
params: {
|
||||
.post<QBittorrentTorrentContents>(
|
||||
`${this.apiBase}/torrents/files`,
|
||||
new URLSearchParams({
|
||||
hash: hash.toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then((res) => res.data);
|
||||
}
|
||||
|
||||
async getTorrentProperties(hash: string): Promise<QBittorrentTorrentProperties> {
|
||||
return axios
|
||||
.get<QBittorrentTorrentProperties>(`${this.apiBase}/torrents/properties`, {
|
||||
params: {
|
||||
.post<QBittorrentTorrentProperties>(
|
||||
`${this.apiBase}/torrents/properties`,
|
||||
new URLSearchParams({
|
||||
hash: hash.toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then((res) => res.data);
|
||||
}
|
||||
|
||||
async getTorrentTrackers(hash: string): Promise<QBittorrentTorrentTrackers> {
|
||||
return axios
|
||||
.get<QBittorrentTorrentTrackers>(`${this.apiBase}/torrents/trackers`, {
|
||||
params: {
|
||||
.post<QBittorrentTorrentTrackers>(
|
||||
`${this.apiBase}/torrents/trackers`,
|
||||
new URLSearchParams({
|
||||
hash: hash.toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then((res) => res.data);
|
||||
}
|
||||
|
||||
async getTransferInfo(): Promise<QBittorrentTransferInfo> {
|
||||
return axios
|
||||
.get<QBittorrentTransferInfo>(`${this.apiBase}/transfer/info`, {
|
||||
.post<QBittorrentTransferInfo>(`${this.apiBase}/transfer/info`, null, {
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
.then((res) => res.data);
|
||||
@@ -175,12 +183,15 @@ class ClientRequestManager {
|
||||
this.isMainDataPending = true;
|
||||
this.syncRids.mainData = this.syncRids.mainData.then((rid) =>
|
||||
axios
|
||||
.get<QBittorrentSyncMainData>(`${this.apiBase}/sync/maindata`, {
|
||||
params: {
|
||||
rid,
|
||||
.post<QBittorrentSyncMainData>(
|
||||
`${this.apiBase}/sync/maindata`,
|
||||
new URLSearchParams({
|
||||
rid: `${rid}`,
|
||||
}),
|
||||
{
|
||||
headers,
|
||||
},
|
||||
headers,
|
||||
})
|
||||
)
|
||||
.then(({data}) => {
|
||||
const {
|
||||
rid: newRid = 0,
|
||||
@@ -268,24 +279,30 @@ class ClientRequestManager {
|
||||
|
||||
async syncTorrentPeers(hash: string): Promise<QBittorrentTorrentPeers> {
|
||||
return axios
|
||||
.get<QBittorrentSyncTorrentPeers>(`${this.apiBase}/sync/torrentPeers`, {
|
||||
params: {
|
||||
.post<QBittorrentSyncTorrentPeers>(
|
||||
`${this.apiBase}/sync/torrentPeers`,
|
||||
new URLSearchParams({
|
||||
hash: hash.toLowerCase(),
|
||||
rid: 0,
|
||||
rid: '0',
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(({data}) => data.peers);
|
||||
}
|
||||
|
||||
async torrentsPause(hashes: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/pause`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/pause`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -293,12 +310,15 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsResume(hashes: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/resume`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/resume`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -306,13 +326,16 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsDelete(hashes: Array<string>, deleteFiles: boolean): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/delete`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/delete`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
deleteFiles: deleteFiles ? 'true' : 'false',
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -320,12 +343,15 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsRecheck(hashes: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/recheck`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/recheck`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -333,13 +359,16 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsSetLocation(hashes: Array<string>, location: string): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/setLocation`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/setLocation`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
location,
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -347,12 +376,15 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsSetTopPrio(hashes: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/topPrio`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/topPrio`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -360,12 +392,15 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsSetBottomPrio(hashes: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/bottomPrio`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/bottomPrio`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -426,13 +461,16 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsAddTags(hashes: Array<string>, tags: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/addTags`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/addTags`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
tags: tags.join(','),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -440,13 +478,16 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsRemoveTags(hashes: Array<string>, tags?: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/removeTags`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/removeTags`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
tags: tags?.join(','),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -455,13 +496,16 @@ class ClientRequestManager {
|
||||
async torrentsAddTrackers(hash: string, urls: Array<string>): Promise<void> {
|
||||
if (urls.length > 0) {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/addTrackers`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/addTrackers`,
|
||||
new URLSearchParams({
|
||||
hash: hash.toLowerCase(),
|
||||
urls: urls.join('\n'),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -471,12 +515,15 @@ class ClientRequestManager {
|
||||
async torrentsReannounce(hashes: Array<string>): Promise<void> {
|
||||
if (hashes.length > 0) {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/reannounce`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/reannounce`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -486,13 +533,16 @@ class ClientRequestManager {
|
||||
async torrentsRemoveTrackers(hash: string, urls: Array<string>): Promise<void> {
|
||||
if (urls.length > 0) {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/removeTrackers`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/removeTrackers`,
|
||||
new URLSearchParams({
|
||||
hash: hash.toLowerCase(),
|
||||
urls: urls.join('|'),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -502,13 +552,16 @@ class ClientRequestManager {
|
||||
async torrentsSetSuperSeeding(hashes: Array<string>, value: boolean): Promise<void> {
|
||||
if (hashes.length > 0) {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/setSuperSeeding`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/setSuperSeeding`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
value: value ? 'true' : 'false',
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -518,12 +571,15 @@ class ClientRequestManager {
|
||||
async torrentsToggleSequentialDownload(hashes: Array<string>): Promise<void> {
|
||||
if (hashes.length > 0) {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/toggleSequentialDownload`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/toggleSequentialDownload`,
|
||||
new URLSearchParams({
|
||||
hashes: hashes.join('|').toLowerCase(),
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
@@ -532,14 +588,17 @@ class ClientRequestManager {
|
||||
|
||||
async torrentsFilePrio(hash: string, ids: Array<number>, priority: QBittorrentTorrentContentPriority) {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/filePrio`, {
|
||||
params: {
|
||||
.post(
|
||||
`${this.apiBase}/torrents/filePrio`,
|
||||
new URLSearchParams({
|
||||
hash: hash.toLowerCase(),
|
||||
id: ids.join('|'),
|
||||
priority,
|
||||
priority: `${priority}`,
|
||||
}),
|
||||
{
|
||||
headers: await this.getRequestHeaders(),
|
||||
},
|
||||
headers: await this.getRequestHeaders(),
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user