fix: simplify and fix configuration generation for services and providers in TorrentioPreset

This commit is contained in:
Viren070
2025-06-20 20:07:38 +01:00
parent ebbd7ec3b2
commit cfafeecda3
+17 -12
View File
@@ -286,19 +286,24 @@ export class TorrentioPreset extends Preset {
providers = TorrentioPreset.defaultProviders;
}
const configString = services.length
? this.urlEncodeKeyValuePairs([
...services.map((service) => [
service,
this.getServiceCredential(service, userData, {
[constants.PUTIO_SERVICE]: (credentials: any) =>
`${credentials.clientId}@${credentials.token}`,
}),
]),
['providers', providers.join(',')],
])
: '';
let config: string[][] = [];
// add services to config
if (services.length) {
// generate a [serviceId, credential] array for each service and push it to config
config = services.map((service) => [
service,
this.getServiceCredential(service, userData, {
[constants.PUTIO_SERVICE]: (credentials: any) =>
`${credentials.clientId}@${credentials.token}`,
}),
]);
}
// add providers to config
config.push(['providers', providers.join(',')]);
const configString = this.urlEncodeKeyValuePairs(config);
return `${url}${configString ? '/' + configString : ''}/manifest.json`;
}
}