21945cc54f
由 163-music-dl CLI 重构为 Web 服务: - 下载流水线、歌词与标签逻辑沿用旧版(node-id3 / ffmpeg) - 网易云(chksz 接口 + music.163.com 元数据)与 QQ 音乐(VIP Cookie)provider - QQ 扫码登录与 musickey 自动续期 - SQLite 持久化的下载队列,SSE 实时进度 - 曲库工具(M3U / ZIP / 回收站 / 补全标签)、历史统计与导出、访问密码 - Vite 8 + Vue 3 前端,浅色 / 深色 - Docker 部署配置(飞牛 NAS) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
// 冒烟测试:用流水线下载一首歌并打印过程事件
|
|
// npm run smoke -- <歌曲ID或链接> [音质] [album|flat]
|
|
// MUSIC_DIR=/tmp/x npm run smoke -- 287398 lossless
|
|
import { importQQCookieFile } from '../src/accounts.ts';
|
|
import { config } from '../src/config.ts';
|
|
import { downloadTrack } from '../src/core/pipeline.ts';
|
|
import { getProvider, resolveLink } from '../src/core/providers/index.ts';
|
|
import { isQualityKey } from '../src/core/quality.ts';
|
|
|
|
importQQCookieFile();
|
|
|
|
const [input, quality = config.defaults.quality, layout = config.defaults.layout] = process.argv.slice(2);
|
|
const ref = input ? await resolveLink(input) : null;
|
|
if (!ref || ref.kind !== 'track' || !isQualityKey(quality)) {
|
|
console.error('用法: npm run smoke -- <歌曲ID或链接> [standard|high|lossless|hires|master|spatial|effect] [album|flat]');
|
|
process.exit(1);
|
|
}
|
|
|
|
const mb = (n: number) => (n / 1048576).toFixed(1);
|
|
const result = await downloadTrack(
|
|
getProvider(ref.source),
|
|
ref.id,
|
|
{ ...config.defaults, quality, layout: layout === 'flat' ? 'flat' : 'album' },
|
|
{
|
|
musicDir: config.musicDir,
|
|
reporter: {
|
|
stage: (stage, msg) => console.log(`▸ [${stage}] ${msg}`),
|
|
progress: (p) => process.stdout.write(`\r ${mb(p.received)}/${mb(p.total)} MB ${(p.speed / 1024).toFixed(0)} KB/s `),
|
|
log: (level, msg) => console.log(`${process.stdout.isTTY ? '\n' : ''} ${level === 'warn' ? '⚠' : '·'} ${msg}`),
|
|
},
|
|
},
|
|
);
|
|
console.log('\n✔', JSON.stringify(result, null, 2));
|