feat: 下载沿用曲库已有的歌手 / 专辑文件夹写法
歌手或专辑文件夹名与曲库已有文件夹只差空格、大小写、全半角时(如 「G.E.M.邓紫棋」与「G.E.M. 邓紫棋」),放进已有文件夹,并把歌手、 专辑歌手标签统一成该写法,避免同一歌手被拆成两个目录 / 两个艺人。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import type { Layout } from '../config.ts';
|
||||
import { resolveTarget } from './layout.ts';
|
||||
import { applyArtistAlias, resolveTarget } from './layout.ts';
|
||||
import { mergeLrc, parseCredits } from './lyrics.ts';
|
||||
import { downloadToFile, fetchBuffer, type Progress } from './net/http.ts';
|
||||
import type { QualityKey } from './quality.ts';
|
||||
@@ -100,7 +100,7 @@ async function downloadOnce(provider: MusicProvider, id: string, opts: DownloadO
|
||||
reporter?.stage?.('metadata', '获取元数据');
|
||||
const meta = await provider.getTrackMeta(id).catch(() => null);
|
||||
const name = audio.name || meta?.name || id;
|
||||
const artists = audio.artists || meta?.artists || '未知歌手';
|
||||
let artists = audio.artists || meta?.artists || '未知歌手';
|
||||
const album = audio.album || meta?.album || '';
|
||||
|
||||
const target = resolveTarget(ctx.musicDir, opts.layout, {
|
||||
@@ -111,6 +111,15 @@ async function downloadOnce(provider: MusicProvider, id: string, opts: DownloadO
|
||||
trackNo: meta?.trackNo,
|
||||
trackTotal: meta?.trackTotal,
|
||||
});
|
||||
// 沿用了曲库已有的歌手文件夹名(如「G.E.M. 邓紫棋」)时,标签里的歌手名也统一成该写法
|
||||
if (target.artistAlias) {
|
||||
artists = applyArtistAlias(artists, target.artistAlias)!;
|
||||
if (meta) {
|
||||
meta.albumArtist = applyArtistAlias(meta.albumArtist, target.artistAlias);
|
||||
meta.albumArtistPrimary = target.artistAlias.to;
|
||||
}
|
||||
reporter?.log?.('info', `歌手名统一为曲库已有写法:${target.artistAlias.to}`);
|
||||
}
|
||||
await fs.promises.mkdir(target.dir, { recursive: true });
|
||||
const dest = path.join(target.dir, `${target.baseName}.${audio.ext}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user