feat: make webdav credentials optional for nzbdav

closes #480
This commit is contained in:
Viren070
2025-11-10 18:00:15 +00:00
parent 8f29d017ba
commit 2ba2677466
4 changed files with 26 additions and 16 deletions
+16 -8
View File
@@ -332,7 +332,12 @@ export abstract class BaseDebridAddon<T extends BaseDebridConfig> {
encryptedStoreAuths,
metadataId
);
if (result.service?.id === 'nzbdav' && nzbdavAuth) {
if (
result.service?.id === 'nzbdav' &&
nzbdavAuth &&
nzbdavAuth.webdavUser &&
nzbdavAuth.webdavPassword
) {
stream.behaviorHints = {
...stream.behaviorHints,
notWebReady: true,
@@ -374,13 +379,16 @@ export abstract class BaseDebridAddon<T extends BaseDebridConfig> {
.map((stream) => ({
url: stream.url!,
filename: stream.behaviorHints?.filename ?? undefined,
headers: {
request: {
Authorization: `Basic ${Buffer.from(
`${nzbdavAuth.webdavUser}:${nzbdavAuth.webdavPassword}`
).toString('base64')}`,
},
},
headers:
nzbdavAuth.webdavUser && nzbdavAuth.webdavPassword
? {
request: {
Authorization: `Basic ${Buffer.from(
`${nzbdavAuth.webdavUser}:${nzbdavAuth.webdavPassword}`
).toString('base64')}`,
},
}
: undefined,
}))
);
+2 -2
View File
@@ -20,8 +20,8 @@ export const NzbDavConfig = z.object({
.optional()
.transform((s) => s?.trim().replace(/^\/+/, '').replace(/\/+$/, '')),
nzbdavApiKey: z.string(),
webdavUser: z.string(),
webdavPassword: z.string(),
webdavUser: z.string().optional(),
webdavPassword: z.string().optional(),
aiostreamsAuth: z.string().optional(),
});
@@ -383,8 +383,8 @@ export class SABnzbdApi {
export interface UsenetStreamServiceConfig {
webdavUrl: string;
publicWebdavUrl: string;
webdavUser: string;
webdavPassword: string;
webdavUser?: string;
webdavPassword?: string;
apiUrl: string;
apiKey: string;
aiostreamsAuth?: string;
@@ -806,8 +806,10 @@ export abstract class UsenetStreamService implements DebridService {
protected getPublicWebdavUrlWithAuth(): string {
let url = new URL(this.auth.publicWebdavUrl);
url.username = encodeURIComponent(this.auth.webdavUser);
url.password = encodeURIComponent(this.auth.webdavPassword);
if (this.auth.webdavUser && this.auth.webdavPassword) {
url.username = encodeURIComponent(this.auth.webdavUser);
url.password = encodeURIComponent(this.auth.webdavPassword);
}
return url.toString().replace(/\/+$/, ''); // Remove trailing slash
}
}
+2 -2
View File
@@ -431,7 +431,7 @@ const SERVICE_DETAILS: Record<
description:
'Your Nzb DAV WebDAV Username. Found in the WebDAV section in settings.',
type: 'string',
required: true,
required: false,
},
{
id: 'password',
@@ -439,7 +439,7 @@ const SERVICE_DETAILS: Record<
description:
'Your NzbDAV WebDAV Password. Found in the WebDAV section in settings.',
type: 'password',
required: true,
required: false,
},
{
id: 'aiostreamsAuth',