|
@@ -22,6 +22,7 @@ const TAG = 'heanup WebdavManager';
|
|
|
export interface WebDavAuthInfo {
|
|
export interface WebDavAuthInfo {
|
|
|
headers: Record<string, string>;
|
|
headers: Record<string, string>;
|
|
|
url: string;
|
|
url: string;
|
|
|
|
|
+ accountId?: string; // 添加账号ID字段,用于标识认证信息对应的账号
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 流媒体认证信息接口
|
|
// 流媒体认证信息接口
|
|
@@ -124,6 +125,271 @@ export class WebdavManager {
|
|
|
|
|
|
|
|
// ==================== 数据库操作 ====================
|
|
// ==================== 数据库操作 ====================
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据webdav_account_id查询WebDAV账号信息
|
|
|
|
|
+ * @param accountId WebDAV账号ID
|
|
|
|
|
+ * @returns Promise<WebDavAccount | null> 返回WebDAV账号信息或null
|
|
|
|
|
+ */
|
|
|
|
|
+ public async getWebDavAccountById(accountId: string): Promise<WebDavAccount | null> {
|
|
|
|
|
+ if (!accountId) {
|
|
|
|
|
+ Logger.warn(TAG, 'webdav_account_id为空,无法查询账号信息');
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const db = await this.dataBaseUtil.getDB();
|
|
|
|
|
+ const predicates = new relationalStore.RdbPredicates(this.webDavTable);
|
|
|
|
|
+ predicates.equalTo('id', accountId);
|
|
|
|
|
+
|
|
|
|
|
+ const resultSet = await db.query(predicates);
|
|
|
|
|
+ if (resultSet.rowCount > 0) {
|
|
|
|
|
+ resultSet.goToFirstRow();
|
|
|
|
|
+ const account = new WebDavAccount();
|
|
|
|
|
+ account.id = resultSet.getLong(resultSet.getColumnIndex('id'));
|
|
|
|
|
+ account.name = resultSet.getString(resultSet.getColumnIndex('name'));
|
|
|
|
|
+ account.host = resultSet.getString(resultSet.getColumnIndex('host'));
|
|
|
|
|
+ account.localHost = resultSet.getString(resultSet.getColumnIndex('localHost'));
|
|
|
|
|
+ account.isUseLocalHost = resultSet.getLong(resultSet.getColumnIndex('isUseLocalHost')) === 1;
|
|
|
|
|
+ account.port = resultSet.getLong(resultSet.getColumnIndex('port'));
|
|
|
|
|
+ account.filepath = resultSet.getString(resultSet.getColumnIndex('filepath'));
|
|
|
|
|
+ account.imageFilePath = resultSet.getString(resultSet.getColumnIndex('imageFilePath'));
|
|
|
|
|
+ account.lyricFilePath = resultSet.getString(resultSet.getColumnIndex('lyricFilePath'));
|
|
|
|
|
+ account.uploadFilePath = resultSet.getString(resultSet.getColumnIndex('uploadFilePath'));
|
|
|
|
|
+ account.account = resultSet.getString(resultSet.getColumnIndex('account'));
|
|
|
|
|
+ account.password = resultSet.getString(resultSet.getColumnIndex('password'));
|
|
|
|
|
+ account.enableHttps = resultSet.getLong(resultSet.getColumnIndex('enableHttps')) === 1;
|
|
|
|
|
+ account.coverPath = resultSet.getString(resultSet.getColumnIndex('coverPath'));
|
|
|
|
|
+ account.isActivate = resultSet.getLong(resultSet.getColumnIndex('isActivate')) === 1;
|
|
|
|
|
+
|
|
|
|
|
+ resultSet.close();
|
|
|
|
|
+ Logger.info(TAG, `成功查询到WebDAV账号: ${account.name}, ID: ${account.id}`);
|
|
|
|
|
+ return account;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn(TAG, `未找到ID为 ${accountId} 的WebDAV账号`);
|
|
|
|
|
+ resultSet.close();
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ const err = error as Error;
|
|
|
|
|
+ Logger.error(TAG, `查询WebDAV账号失败: ${err.message}`);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据WebDAV账号构建认证信息
|
|
|
|
|
+ * @param accountId WebDAV账号ID
|
|
|
|
|
+ * @returns Promise<WebDavAuthInfo | null> 返回认证信息或null
|
|
|
|
|
+ */
|
|
|
|
|
+ public async buildAuthInfoByAccountId(accountId: string): Promise<WebDavAuthInfo | null> {
|
|
|
|
|
+ const account = await this.getWebDavAccountById(accountId);
|
|
|
|
|
+ if (!account) {
|
|
|
|
|
+ Logger.warn(TAG, `无法构建认证信息,账号ID ${accountId} 对应的账号不存在`);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 构建基础URL
|
|
|
|
|
+ const protocol = account.enableHttps ? 'https' : 'http';
|
|
|
|
|
+ const host = account.isUseLocalHost && account.localHost ? account.localHost : account.host;
|
|
|
|
|
+ const port = account.port && account.port !== 80 && account.port !== 443 ? `:${account.port}` : '';
|
|
|
|
|
+ const baseUrl = `${protocol}://${host}${port}`;
|
|
|
|
|
+
|
|
|
|
|
+ // 构建认证头
|
|
|
|
|
+ const headers: Record<string, string> = {};
|
|
|
|
|
+ if (account.account && account.password) {
|
|
|
|
|
+ const credentials = `${account.account}:${account.password}`;
|
|
|
|
|
+ // 简化base64编码实现,避免复杂的类型转换
|
|
|
|
|
+ try {
|
|
|
|
|
+ const bufferObj = buffer.from(credentials, 'utf-8');
|
|
|
|
|
+ const base64Credentials = bufferObj.toString('base64');
|
|
|
|
|
+ headers['Authorization'] = `Basic ${base64Credentials}`;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ const err = error as Error;
|
|
|
|
|
+ Logger.warn(TAG, `base64编码失败,使用原始凭据: ${err.message}`);
|
|
|
|
|
+ headers['Authorization'] = `Basic ${credentials}`;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Logger.info(TAG, `成功构建WebDAV认证信息,账号: ${account.name}, URL: ${baseUrl}`);
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ headers: headers,
|
|
|
|
|
+ url: baseUrl,
|
|
|
|
|
+ accountId: accountId
|
|
|
|
|
+ };
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ const err = error as Error;
|
|
|
|
|
+ Logger.error(TAG, `构建WebDAV认证信息失败: ${err.message}`);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建HTTP请求头,通过webdav_account_id查询认证信息
|
|
|
|
|
+ * @param currentSong - 当前播放的歌曲信息
|
|
|
|
|
+ * @param videoUrl - 当前歌曲的URL
|
|
|
|
|
+ * @returns Promise<Map<string, string>> HTTP请求头
|
|
|
|
|
+ */
|
|
|
|
|
+ public async buildHttpHeadersWithAccountId(
|
|
|
|
|
+ currentSong: VideoItem | undefined,
|
|
|
|
|
+ videoUrl: string
|
|
|
|
|
+ ): Promise<Map<string, string>> {
|
|
|
|
|
+ const headers = new Map<string, string>();
|
|
|
|
|
+
|
|
|
|
|
+ if (!currentSong) {
|
|
|
|
|
+ return headers;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Logger.info(`heanup 当前歌曲信息 - name: ${currentSong.name}, type: ${currentSong.type}, filePath: ${currentSong.filePath}`);
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否为WebDAV歌曲
|
|
|
|
|
+ if (currentSong.type === CommonConstants.TYPE_WEBDAV) {
|
|
|
|
|
+ // 优先使用webdav_account_id查询认证信息
|
|
|
|
|
+ if (currentSong.webdav_account_id) {
|
|
|
|
|
+ Logger.info(`heanup 使用webdav_account_id查询认证信息,账号ID: ${currentSong.webdav_account_id}`);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const authInfo = await this.buildAuthInfoByAccountId(currentSong.webdav_account_id);
|
|
|
|
|
+ if (authInfo) {
|
|
|
|
|
+ // 添加WebDAV认证头
|
|
|
|
|
+ Object.keys(authInfo.headers).forEach(key => {
|
|
|
|
|
+ headers.set(key, authInfo.headers[key]);
|
|
|
|
|
+ });
|
|
|
|
|
+ Logger.info(`heanup 成功通过webdav_account_id获取WebDAV认证信息`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn(`heanup 无法通过webdav_account_id ${currentSong.webdav_account_id} 获取认证信息`);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ const err = error as Error;
|
|
|
|
|
+ Logger.error(`heanup 查询webdav_account_id认证信息时出错: ${err.message}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn(`heanup WebDAV歌曲缺少webdav_account_id字段,无法查询认证信息`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果没有认证信息,记录警告
|
|
|
|
|
+ if (headers.size === 0) {
|
|
|
|
|
+ Logger.warn(`heanup WebDAV歌曲缺少认证信息,可能需要手动配置WebDAV账户`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return headers;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新现有WebDAV歌曲的webdav_account_id字段
|
|
|
|
|
+ * 用于修复旧版本数据库中缺少webdav_account_id的记录
|
|
|
|
|
+ * @param accountId WebDAV账号ID
|
|
|
|
|
+ */
|
|
|
|
|
+ public async updateWebDavSongsAccountId(accountId: string): Promise<void> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const db = await this.dataBaseUtil.getDB();
|
|
|
|
|
+
|
|
|
|
|
+ // 查询所有TYPE_WEBDAV且webdav_account_id为空或null的记录
|
|
|
|
|
+ const querySql = `
|
|
|
|
|
+ SELECT id, filePath FROM mediaTable
|
|
|
|
|
+ WHERE mtype = ${CommonConstants.TYPE_WEBDAV}
|
|
|
|
|
+ AND (webdav_account_id IS NULL OR webdav_account_id = '')
|
|
|
|
|
+ `;
|
|
|
|
|
+
|
|
|
|
|
+ const resultSet = await db.querySql(querySql);
|
|
|
|
|
+ const updateCount = resultSet.rowCount;
|
|
|
|
|
+
|
|
|
|
|
+ if (updateCount > 0) {
|
|
|
|
|
+ Logger.info(TAG, `发现 ${updateCount} 个WebDAV歌曲缺少webdav_account_id,开始更新`);
|
|
|
|
|
+
|
|
|
|
|
+ // 更新这些记录的webdav_account_id
|
|
|
|
|
+ const updateSql = `
|
|
|
|
|
+ UPDATE mediaTable
|
|
|
|
|
+ SET webdav_account_id = ?
|
|
|
|
|
+ WHERE mtype = ${CommonConstants.TYPE_WEBDAV}
|
|
|
|
|
+ AND (webdav_account_id IS NULL OR webdav_account_id = '')
|
|
|
|
|
+ `;
|
|
|
|
|
+
|
|
|
|
|
+ await db.executeSql(updateSql, [accountId]);
|
|
|
|
|
+ Logger.info(TAG, `成功更新 ${updateCount} 个WebDAV歌曲的webdav_account_id为: ${accountId}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.info(TAG, `所有WebDAV歌曲都已有webdav_account_id,无需更新`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ resultSet.close();
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ const err = error as Error;
|
|
|
|
|
+ Logger.error(TAG, `更新WebDAV歌曲webdav_account_id失败: ${err.message}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修复所有WebDAV歌曲的webdav_account_id字段
|
|
|
|
|
+ * 用于全局修复旧版本数据库中缺少webdav_account_id的记录
|
|
|
|
|
+ * @param accountId WebDAV账号ID(可选,如果不提供则使用当前激活的账号)
|
|
|
|
|
+ */
|
|
|
|
|
+ public async fixAllWebDavSongsAccountId(accountId?: string): Promise<void> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 如果没有提供accountId,尝试使用当前激活的账号
|
|
|
|
|
+ if (!accountId) {
|
|
|
|
|
+ const activeAccount = await this.getActiveWebDavAccount();
|
|
|
|
|
+ if (activeAccount && activeAccount.id) {
|
|
|
|
|
+ accountId = activeAccount.id.toString();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Logger.warn(TAG, `无法找到激活的WebDAV账号来修复歌曲记录`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Logger.info(TAG, `开始修复所有WebDAV歌曲的webdav_account_id,使用账号ID: ${accountId}`);
|
|
|
|
|
+ await this.updateWebDavSongsAccountId(accountId);
|
|
|
|
|
+ Logger.info(TAG, `WebDAV歌曲webdav_account_id修复完成`);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ const err = error as Error;
|
|
|
|
|
+ Logger.error(TAG, `修复WebDAV歌曲webdav_account_id失败: ${err.message}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取当前激活的WebDAV账号
|
|
|
|
|
+ */
|
|
|
|
|
+ private async getActiveWebDavAccount(): Promise<WebDavAccount | null> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const db = await this.dataBaseUtil.getDB();
|
|
|
|
|
+ const predicates = new relationalStore.RdbPredicates(this.webDavTable);
|
|
|
|
|
+ predicates.equalTo('isActivate', 1);
|
|
|
|
|
+ predicates.limitAs(1);
|
|
|
|
|
+
|
|
|
|
|
+ const resultSet = await db.query(predicates);
|
|
|
|
|
+ if (resultSet.rowCount > 0) {
|
|
|
|
|
+ resultSet.goToFirstRow();
|
|
|
|
|
+ const account = new WebDavAccount();
|
|
|
|
|
+ account.id = resultSet.getLong(resultSet.getColumnIndex('id'));
|
|
|
|
|
+ account.name = resultSet.getString(resultSet.getColumnIndex('name'));
|
|
|
|
|
+ account.host = resultSet.getString(resultSet.getColumnIndex('host'));
|
|
|
|
|
+ account.localHost = resultSet.getString(resultSet.getColumnIndex('localHost'));
|
|
|
|
|
+ account.isUseLocalHost = resultSet.getLong(resultSet.getColumnIndex('isUseLocalHost')) === 1;
|
|
|
|
|
+ account.port = resultSet.getLong(resultSet.getColumnIndex('port'));
|
|
|
|
|
+ account.filepath = resultSet.getString(resultSet.getColumnIndex('filepath'));
|
|
|
|
|
+ account.imageFilePath = resultSet.getString(resultSet.getColumnIndex('imageFilePath'));
|
|
|
|
|
+ account.lyricFilePath = resultSet.getString(resultSet.getColumnIndex('lyricFilePath'));
|
|
|
|
|
+ account.uploadFilePath = resultSet.getString(resultSet.getColumnIndex('uploadFilePath'));
|
|
|
|
|
+ account.account = resultSet.getString(resultSet.getColumnIndex('account'));
|
|
|
|
|
+ account.password = resultSet.getString(resultSet.getColumnIndex('password'));
|
|
|
|
|
+ account.enableHttps = resultSet.getLong(resultSet.getColumnIndex('enableHttps')) === 1;
|
|
|
|
|
+ account.coverPath = resultSet.getString(resultSet.getColumnIndex('coverPath'));
|
|
|
|
|
+ account.isActivate = resultSet.getLong(resultSet.getColumnIndex('isActivate')) === 1;
|
|
|
|
|
+
|
|
|
|
|
+ resultSet.close();
|
|
|
|
|
+ return account;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ resultSet.close();
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ const err = error as Error;
|
|
|
|
|
+ Logger.error(TAG, `获取激活的WebDAV账号失败: ${err.message}`);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 创建WebDAV账户表
|
|
// 创建WebDAV账户表
|
|
|
public createWebDavTableInDB(): Promise<void> {
|
|
public createWebDavTableInDB(): Promise<void> {
|
|
|
const createTableSql = `CREATE TABLE IF NOT EXISTS ${this.webDavTable} (
|
|
const createTableSql = `CREATE TABLE IF NOT EXISTS ${this.webDavTable} (
|
|
@@ -440,6 +706,11 @@ export class WebdavManager {
|
|
|
public async loadFilesInfoFromAccount(account: WebDavAccount,customPath?: string): Promise<void> {
|
|
public async loadFilesInfoFromAccount(account: WebDavAccount,customPath?: string): Promise<void> {
|
|
|
this.currentAccount = account;
|
|
this.currentAccount = account;
|
|
|
|
|
|
|
|
|
|
+ // 更新现有WebDAV歌曲的webdav_account_id字段
|
|
|
|
|
+ if (account && account.id) {
|
|
|
|
|
+ await this.updateWebDavSongsAccountId(account.id.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
this.notifyObservers(WebdavManagerStates.LoadFilesInfoStart);
|
|
this.notifyObservers(WebdavManagerStates.LoadFilesInfoStart);
|
|
|
|
|
|
|
@@ -531,6 +802,12 @@ export class WebdavManager {
|
|
|
videoItem.artist = musicData.artist
|
|
videoItem.artist = musicData.artist
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 设置WebDAV账号ID,用于后续认证信息查询
|
|
|
|
|
+ if (account && account.id) {
|
|
|
|
|
+ videoItem.webdav_account_id = account.id.toString();
|
|
|
|
|
+ Logger.info(TAG, `设置WebDAV歌曲 ${videoItem.name} 的账号ID: ${videoItem.webdav_account_id}`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return videoItem;
|
|
return videoItem;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -740,17 +1017,17 @@ export class WebdavManager {
|
|
|
// ==================== 安全认证方法 ====================
|
|
// ==================== 安全认证方法 ====================
|
|
|
|
|
|
|
|
// 获取WebDAV认证信息(用于播放器)
|
|
// 获取WebDAV认证信息(用于播放器)
|
|
|
- public getWebDavAuthHeaders(accountId: number): WebDavAuthInfo | null {
|
|
|
|
|
- const account = this.getWebDavAccountById(accountId);
|
|
|
|
|
|
|
+ public async getWebDavAuthHeaders(accountId: string): Promise<WebDavAuthInfo | null> {
|
|
|
|
|
+ const account = await this.getWebDavAccountById(accountId);
|
|
|
if (!account || !account.account || !account.password) {
|
|
if (!account || !account.account || !account.password) {
|
|
|
Logger.error(TAG, '无效的WebDAV账户或缺少认证信息');
|
|
Logger.error(TAG, '无效的WebDAV账户或缺少认证信息');
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 构建基础URL
|
|
// 构建基础URL
|
|
|
- const protocol = account.enableHttps ? 'https' : 'http';
|
|
|
|
|
- const host = account.isUseLocalHost ? account.localHost : account.host;
|
|
|
|
|
- const port = account.port;
|
|
|
|
|
|
|
+ const protocol: string = account.enableHttps ? 'https' : 'http';
|
|
|
|
|
+ const host: string = account.isUseLocalHost && account.localHost ? account.localHost : account.host;
|
|
|
|
|
+ const port: number = account.port;
|
|
|
|
|
|
|
|
// 构建认证头
|
|
// 构建认证头
|
|
|
const credentials = buffer
|
|
const credentials = buffer
|
|
@@ -762,21 +1039,12 @@ export class WebdavManager {
|
|
|
'Authorization': `Basic ${credentials}`,
|
|
'Authorization': `Basic ${credentials}`,
|
|
|
'User-Agent': 'TTMusic/1.0'
|
|
'User-Agent': 'TTMusic/1.0'
|
|
|
},
|
|
},
|
|
|
- url: `${protocol}://${host}:${port}`
|
|
|
|
|
|
|
+ url: `${protocol}://${host}:${port}`,
|
|
|
|
|
+ accountId: accountId
|
|
|
};
|
|
};
|
|
|
return authInfo;
|
|
return authInfo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 根据ID获取WebDAV账户
|
|
|
|
|
- private getWebDavAccountById(accountId: number): WebDavAccount | null {
|
|
|
|
|
- for (let i = 0; i < this.webDavAccounts.length; i++) {
|
|
|
|
|
- const account = this.webDavAccounts[i];
|
|
|
|
|
- if (account.id === accountId) {
|
|
|
|
|
- return account;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -786,13 +1054,13 @@ export class WebdavManager {
|
|
|
* @param currentSong - 当前播放的歌曲信息
|
|
* @param currentSong - 当前播放的歌曲信息
|
|
|
* @param videoUrl - 当前歌曲的URL
|
|
* @param videoUrl - 当前歌曲的URL
|
|
|
* @param webDavAuthItem - 当前WebDAV认证信息(实例变量)
|
|
* @param webDavAuthItem - 当前WebDAV认证信息(实例变量)
|
|
|
- * @returns Map<string, string> HTTP请求头
|
|
|
|
|
|
|
+ * @returns Promise<Map<string, string>> HTTP请求头
|
|
|
*/
|
|
*/
|
|
|
-export function buildHttpHeadersWithWebDav(
|
|
|
|
|
|
|
+export async function buildHttpHeadersWithWebDav(
|
|
|
currentSong: VideoItem | undefined,
|
|
currentSong: VideoItem | undefined,
|
|
|
videoUrl: string,
|
|
videoUrl: string,
|
|
|
webDavAuthItem: WebDavAuthItem
|
|
webDavAuthItem: WebDavAuthItem
|
|
|
-): Map<string, string> {
|
|
|
|
|
|
|
+): Promise<Map<string, string>> {
|
|
|
const headers = new Map<string, string>();
|
|
const headers = new Map<string, string>();
|
|
|
|
|
|
|
|
let isWebDavSong = false;
|
|
let isWebDavSong = false;
|
|
@@ -837,7 +1105,7 @@ export function buildHttpHeadersWithWebDav(
|
|
|
Logger.info(`heanup 找到WebDAV认证信息,账户ID: ${webDavAuthItem.accountId}`);
|
|
Logger.info(`heanup 找到WebDAV认证信息,账户ID: ${webDavAuthItem.accountId}`);
|
|
|
// 使用WebdavManager获取认证头
|
|
// 使用WebdavManager获取认证头
|
|
|
const webdavManager = WebdavManager.getInstance();
|
|
const webdavManager = WebdavManager.getInstance();
|
|
|
- const authHeaders = webdavManager.getWebDavAuthHeaders(webDavAuthItem.accountId);
|
|
|
|
|
|
|
+ const authHeaders = await webdavManager.getWebDavAuthHeaders(webDavAuthItem.accountId.toString());
|
|
|
|
|
|
|
|
if (authHeaders) {
|
|
if (authHeaders) {
|
|
|
// 添加Basic认证头
|
|
// 添加Basic认证头
|