🔀 Merge pull request #252 from LarveyOfficial/fix-multiple-download-clients

🐛Allow multiple of the same torrent client +1
This commit is contained in:
Thomas Camlong
2022-06-21 16:22:18 +02:00
committed by GitHub
2 changed files with 102 additions and 85 deletions

View File

@@ -298,53 +298,64 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
</> </>
)} )}
{form.values.type === 'qBittorrent' && ( {form.values.type === 'qBittorrent' && (
<> <>
<TextInput <TextInput
required required
label="Username" label="Username"
placeholder="admin" placeholder="admin"
value={form.values.username} value={form.values.username}
onChange={(event) => { onChange={(event) => {
form.setFieldValue('username', event.currentTarget.value); form.setFieldValue('username', event.currentTarget.value);
}} }}
error={form.errors.username && 'Invalid username'} error={form.errors.username && 'Invalid username'}
/> />
<TextInput <TextInput
required required
label="Password" label="Password"
placeholder="adminadmin" placeholder="adminadmin"
value={form.values.password} value={form.values.password}
onChange={(event) => { onChange={(event) => {
form.setFieldValue('password', event.currentTarget.value); form.setFieldValue('password', event.currentTarget.value);
}} }}
error={form.errors.password && 'Invalid password'} error={form.errors.password && 'Invalid password'}
/> />
</> </>
)} )}
{(form.values.type === 'Deluge' || {form.values.type === 'Deluge' && (
form.values.type === 'Transmission' || <>
form.values.type === 'qBittorrent') && ( <TextInput
<> label="Password"
<TextInput placeholder="password"
label="Username" value={form.values.password}
placeholder="admin" onChange={(event) => {
value={form.values.username} form.setFieldValue('password', event.currentTarget.value);
onChange={(event) => { }}
form.setFieldValue('username', event.currentTarget.value); error={form.errors.password && 'Invalid password'}
}} />
error={form.errors.username && 'Invalid username'} </>
/> )}
<TextInput {form.values.type === 'Transmission' && (
label="Password" <>
placeholder="password" <TextInput
value={form.values.password} label="Username"
onChange={(event) => { placeholder="admin"
form.setFieldValue('password', event.currentTarget.value); value={form.values.username}
}} onChange={(event) => {
error={form.errors.password && 'Invalid password'} form.setFieldValue('username', event.currentTarget.value);
/> }}
</> error={form.errors.username && 'Invalid username'}
)} />
<TextInput
label="Password"
placeholder="adminadmin"
value={form.values.password}
onChange={(event) => {
form.setFieldValue('password', event.currentTarget.value);
}}
error={form.errors.password && 'Invalid password'}
/>
</>
)}
</Group> </Group>
</ScrollArea> </ScrollArea>
</Tabs.Tab> </Tabs.Tab>

View File

@@ -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: 'username' in service ? service.username : '',
}).getAllData() password: 'password' in service ? service.password : '',
).torrents }).getAllData()
); ).torrents
);
}
} }
res.status(200).json(torrents); res.status(200).json(torrents);
} }