fix(backend): Live-Mitschnitte aus der Suche ausschliessen
is_live meint nur "laeuft gerade als Stream" — eine Konzert-AUFNAHME kam
ungehindert durch und landete als Albumtrack in der Bibliothek ("Dat Adam - Ufo
Video Days 2015 Live" auf dem echten Kuenstlerkanal, Dauer im Fenster). Der
Variantenfilter bekommt daher eine live-Regel. Sie schaltet sich ab, wenn der
gesuchte Titel selbst live enthaelt; die Pruefung nutzt \blive\b statt includes,
sonst wuerde "deliver" die Regel aushebeln. Drei Tests dazu.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d8a8a1d5e
commit
33b3df609a
4 files changed
+54
-2
No files matched your search
+10
-2
@@ -71,8 +71,16 @@ function buildVariantFilter(title) {
|
||||
{ key: 'cover', expr: 'title !~= (?i)\\bcover\\b' },
|
||||
{ key: 'acoustic', expr: 'title !~= (?i)\\bacoustic\\b' },
|
||||
{ key: 'instrumental', expr: 'title !~= (?i)\\binstrumental\\b' },
|
||||
// Konzertmitschnitte: `!is_live` heisst nur "laeuft nicht gerade als Stream" und laesst eine
|
||||
// Live-AUFNAHME durch. Auf dem echten Kuenstlerkanal ist die sonst nicht vom Studiotrack zu
|
||||
// unterscheiden — so landete "Dat Adam - Ufo Video Days 2015 Live" in der Bibliothek.
|
||||
// skipRe statt includes(): "deliver"/"delivery" enthalten "live" als Teilstring und wuerden
|
||||
// die Regel sonst faelschlich abschalten.
|
||||
{ key: 'live', expr: 'title !~= (?i)\\blive\\b', skipRe: /\blive\b/i },
|
||||
];
|
||||
const parts = RULES.filter(r => !t.includes(r.key)).map(r => r.expr);
|
||||
// Eine Regel entfaellt, wenn der GESUCHTE Titel das Wort selbst traegt — wer "Live Forever" oder
|
||||
// bewusst eine Live-Version sucht, soll sie auch bekommen.
|
||||
const parts = RULES.filter(r => r.skipRe ? !r.skipRe.test(t) : !t.includes(r.key)).map(r => r.expr);
|
||||
return parts.length ? parts.join(' & ') : '';
|
||||
}
|
||||
|
||||
@@ -445,4 +453,4 @@ async function embedMetadata({ jobId, audioFile, dir, trackPrefix, safeTitle, ra
|
||||
return { success: true, dir };
|
||||
}
|
||||
|
||||
module.exports = { downloadTrack, embedMetadata, buildTitleKeywords };
|
||||
module.exports = { downloadTrack, embedMetadata, buildTitleKeywords, buildVariantFilter };
|
||||
@@ -45,3 +45,34 @@ test('a year that IS the title stays required', () => {
|
||||
assert.equal(accepts('1999', 'Prince - 1999 (Official Music Video)'), true);
|
||||
assert.equal(accepts('1999', 'Prince - 1984 (Official Music Video)'), false);
|
||||
});
|
||||
|
||||
const { buildVariantFilter } = require('../lib/ytdlp.js');
|
||||
|
||||
// Der Variantenfilter ist eine yt-dlp-Ausdruckskette "title !~= (?i)\bx\b & …".
|
||||
// Diese Hilfsfunktion wertet sie so aus, wie yt-dlp es tut.
|
||||
const variantAccepts = (searchTitle, candidate) => {
|
||||
const f = buildVariantFilter(searchTitle);
|
||||
if (!f) return true;
|
||||
return f.split(' & ').every(part => {
|
||||
const m = /^title !~= \(\?i\)(.+)$/.exec(part);
|
||||
return !new RegExp(m[1], 'i').test(candidate);
|
||||
});
|
||||
};
|
||||
|
||||
test('rejects a live recording — is_live only covers running streams', () => {
|
||||
// Der echte Fall: auf dem Kuenstlerkanal, Dauer im Fenster, Titel passend.
|
||||
assert.equal(variantAccepts('UFO', 'Dat Adam - Ufo Video Days 2015 Live'), false);
|
||||
assert.equal(variantAccepts('UFO', 'DAT ADAM - 700 Main St | ROCK AM RING 2017 [LIVE]'), false);
|
||||
assert.equal(variantAccepts('UFO', 'UFO'), true);
|
||||
});
|
||||
|
||||
test('a deliberately live title keeps its live results', () => {
|
||||
assert.equal(variantAccepts('Live Forever', 'Oasis - Live Forever'), true);
|
||||
assert.equal(variantAccepts('Unplugged in New York (Live)', 'Nirvana - All Apologies (Live)'), true);
|
||||
});
|
||||
|
||||
test('"live" inside another word does not disable the rule', () => {
|
||||
// "deliver" enthaelt "live" als Teilstring — die Regel muss trotzdem greifen.
|
||||
assert.equal(variantAccepts('Deliver', 'Artist - Deliver (Live at Wembley)'), false);
|
||||
assert.equal(variantAccepts('Deliver', 'Artist - Deliver'), true);
|
||||
});
|
||||
Reference in new issue
Block a user