mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 07:55:52 +01:00
🐛Allow multiple of the same torrent client
Allows multiple of the same type of torrent client
This commit is contained in:
@@ -9,50 +9,56 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
// Get the type of service from the request url
|
// Get the type of service from the request url
|
||||||
const torrents: NormalizedTorrent[] = [];
|
const torrents: NormalizedTorrent[] = [];
|
||||||
const { config }: { config: Config } = req.body;
|
const { config }: { config: Config } = req.body;
|
||||||
const qBittorrentService = config.services
|
const qBittorrentServices = config.services
|
||||||
.filter((service) => service.type === 'qBittorrent')
|
.filter((service) => service.type === 'qBittorrent');
|
||||||
.at(0);
|
|
||||||
const delugeService = config.services.filter((service) => service.type === 'Deluge').at(0);
|
const delugeServices = config.services.filter((service) => service.type === 'Deluge');
|
||||||
const transmissionService = config.services
|
const transmissionServices = config.services
|
||||||
.filter((service) => service.type === 'Transmission')
|
.filter((service) => service.type === 'Transmission');
|
||||||
.at(0);
|
|
||||||
if (!qBittorrentService && !delugeService && !transmissionService) {
|
if (!qBittorrentServices && !delugeServices && !transmissionServices) {
|
||||||
return res.status(500).json({
|
return res.status(500).json({
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
message: 'Missing service',
|
message: 'Missing services',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (qBittorrentService) {
|
if (qBittorrentServices) {
|
||||||
torrents.push(
|
for (const service of qBittorrentServices) {
|
||||||
...(
|
torrents.push(
|
||||||
await new QBittorrent({
|
...(
|
||||||
baseUrl: qBittorrentService.url,
|
await new QBittorrent({
|
||||||
username: qBittorrentService.username,
|
baseUrl: service.url,
|
||||||
password: qBittorrentService.password,
|
username: service.username,
|
||||||
}).getAllData()
|
password: service.password,
|
||||||
).torrents
|
}).getAllData()
|
||||||
);
|
).torrents
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (delugeService) {
|
if (delugeServices) {
|
||||||
torrents.push(
|
for (const service of delugeServices) {
|
||||||
...(
|
torrents.push(
|
||||||
await new Deluge({
|
...(
|
||||||
baseUrl: delugeService.url,
|
await new Deluge({
|
||||||
password: 'password' in delugeService ? delugeService.password : '',
|
baseUrl: service.url,
|
||||||
}).getAllData()
|
password: 'password' in service ? service.password : '',
|
||||||
).torrents
|
}).getAllData()
|
||||||
);
|
).torrents
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (transmissionService) {
|
if (transmissionServices) {
|
||||||
torrents.push(
|
for (const service of transmissionServices) {
|
||||||
...(
|
torrents.push(
|
||||||
await new Transmission({
|
...(
|
||||||
baseUrl: transmissionService.url,
|
await new Transmission({
|
||||||
username: transmissionService.username,
|
baseUrl: service.url,
|
||||||
password: 'password' in transmissionService ? transmissionService.password : '',
|
username: service.username,
|
||||||
}).getAllData()
|
password: 'password' in service ? service.password : '',
|
||||||
).torrents
|
}).getAllData()
|
||||||
);
|
).torrents
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.status(200).json(torrents);
|
res.status(200).json(torrents);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user