data: 添加HAKUSH数据下载/建模

This commit is contained in:
bietiaop 2024-08-24 21:23:50 +08:00
parent d082c87809
commit 1c4798f9b8
7 changed files with 491 additions and 9 deletions

View file

@ -1,7 +1,8 @@
import path from 'path';
import { checkFile } from './core.js';
import { getResourceRemotePath } from '../assets.js';
import * as MysURL from '../mysapi/api.js';
import * as MysURL from '../assets/mysurl.js';
import * as HakushURL from '../assets/hakushurl.js';
import * as LocalURI from './const.js';
/**
* 下载米游社图片
@ -55,3 +56,20 @@ export const downloadResourceImage = async (
}
return result;
};
/**
* 下载Hakush文件
* @param {keyof HakushURL} base 远程地址
* @param {keyof LocalURI} localBase 本地地址
* @param {string} filename 文件名
*/
export const downloadHakushFile = async (base, localBase, filename = '') => {
base = HakushURL[base];
localBase = LocalURI[localBase];
const finalPath = path.join(localBase, filename);
let url = base;
if (filename) {
url += `/${filename}`;
}
return checkFile(url, finalPath);
};