fix(backend): Schraegstrich im Namen und zu lockere Titelsuche fuehrten auf die falsche Datei
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb72e5c27d
commit
24558497da
4 files changed
+193
-53
No files matched your search
@@ -113,3 +113,60 @@ test('die Zweitpruefung schliesst die Luecke, ohne Fremdes zu treffen', () => {
|
||||
// Remix bleibt auch ueber zwei Durchlaeufe hinweg eigenstaendig.
|
||||
assert.equal(pruefe('Arcane', 'Bea Miller', 'Playground (Remix)'), null);
|
||||
});
|
||||
|
||||
// ─── Dateisuche: Titelstamm und Schraegstrich im Namen ───────────────────────
|
||||
// Regression zu "K/DA – VILLAIN": Navidromes Tag-Pfad wurde zu "K/DA/ALL OUT/…", auf der Platte
|
||||
// steht "K_DA/ALL OUT/…". Der Pfad fand nichts, und die Aehnlichkeitssuche lieferte
|
||||
// "Bad Omens - Like A Villain", weil deren Stamm auf "villain" ENDET.
|
||||
const { findFileByStem, albumDirFromTags } = require('../lib/metadata');
|
||||
|
||||
let SLASH_ROOT;
|
||||
before(() => {
|
||||
SLASH_ROOT = fs.mkdtempSync(path.join(os.tmpdir(), 'ns-slash-'));
|
||||
const put = (...segs) => {
|
||||
const file = segs.pop();
|
||||
const dir = path.join(SLASH_ROOT, ...segs);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(path.join(dir, file), '');
|
||||
};
|
||||
put('K_DA', 'ALL OUT', '03 - K_DA - VILLAIN.mp3');
|
||||
put('K_DA', 'POP_STARS', '01 - K_DA - POP_STARS.mp3');
|
||||
put('Bad Omens', 'THE DEATH OF PEACE OF MIND', '06 - Bad Omens - Like A Villain.mp3');
|
||||
});
|
||||
after(() => { try { fs.rmSync(SLASH_ROOT, { recursive: true, force: true }); } catch {} });
|
||||
|
||||
test('Titelstamm trifft nicht auf blosse Endsilbe', () => {
|
||||
// "Like A Villain" darf NICHT als "VILLAIN" durchgehen
|
||||
const t = findFileByStem(path.join(SLASH_ROOT, 'Bad Omens'), 'villain');
|
||||
assert.equal(t, null);
|
||||
});
|
||||
|
||||
test('Titelstamm trifft "Kuenstler - Titel" weiterhin', () => {
|
||||
const t = findFileByStem(path.join(SLASH_ROOT, 'Bad Omens'), 'like a villain');
|
||||
assert.ok(t && t.endsWith('06 - Bad Omens - Like A Villain.mp3'));
|
||||
});
|
||||
|
||||
test('Ganze Bibliothek: VILLAIN findet K_DA, nicht Bad Omens', () => {
|
||||
const t = findFileByStem(SLASH_ROOT, 'villain');
|
||||
assert.ok(t && t.includes(path.join('K_DA', 'ALL OUT')), `unerwartet: ${t}`);
|
||||
});
|
||||
|
||||
test('Schraegstrich im Kuenstlernamen fuehrt zum richtigen Ordner', () => {
|
||||
assert.equal(albumDirFromTags(SLASH_ROOT, 'K/DA', 'ALL OUT'), path.join(SLASH_ROOT, 'K_DA', 'ALL OUT'));
|
||||
assert.equal(albumDirFromTags(SLASH_ROOT, 'K/DA', 'POP/STARS'), path.join(SLASH_ROOT, 'K_DA', 'POP_STARS'));
|
||||
});
|
||||
|
||||
test('Unbekanntes Album faellt auf den Kuenstlerordner zurueck', () => {
|
||||
assert.equal(albumDirFromTags(SLASH_ROOT, 'K/DA', 'Gibt Es Nicht'), path.join(SLASH_ROOT, 'K_DA'));
|
||||
});
|
||||
|
||||
test('Mehrere Kuenstler: Ordner haengt am ersten', () => {
|
||||
assert.equal(
|
||||
albumDirFromTags(SLASH_ROOT, 'K/DA, Madison Beer, Kim Petras', 'ALL OUT'),
|
||||
path.join(SLASH_ROOT, 'K_DA', 'ALL OUT'),
|
||||
);
|
||||
});
|
||||
|
||||
test('Kein Treffer bleibt null', () => {
|
||||
assert.equal(albumDirFromTags(SLASH_ROOT, 'Niemand', 'Nichts'), null);
|
||||
});
|
||||
Reference in new issue
Block a user