fix(backend): Zahlen im Titel sind Pflicht-Keywords, Abkuerzungen erlaubt
"700 Main Street" lud "777 Main Street" eines fremden Artists: buildTitleKeywords behielt nur die zwei laengsten Woerter (Street, Main), die unterscheidende 700 fiel als zu kurz raus — und Schritt 3 der Kaskade prueft den Kuenstler-Channel nicht mehr. Zahlen werden jetzt immer als \b<n>\b gefordert. Dazu eine kleine Abkuerzungstabelle (street/st, saint/st, mount/mt, doctor/dr, versus/vs, number/no), denn der korrekte Art Track heisst "700 Main st" und scheiterte bisher an jedem Schritt. Tests in backend/test/ytdlp.test.js. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9f0d4c3153
commit
02b590505a
4 files changed
+75
-4
No files matched your search
@@ -0,0 +1,35 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert');
|
||||
const { buildTitleKeywords } = require('../lib/ytdlp.js');
|
||||
|
||||
// The keywords become `title ~= (?i)<kw>` match-filters in yt-dlp, i.e. every keyword must match
|
||||
// the candidate title case-insensitively. This mirrors that check.
|
||||
const accepts = (title, candidate) =>
|
||||
buildTitleKeywords(title).every(kw => new RegExp(kw, 'i').test(candidate));
|
||||
|
||||
test('a number in the title is always required, however short', () => {
|
||||
const kws = buildTitleKeywords('700 Main Street');
|
||||
assert.ok(kws.some(k => k.includes('700')), `700 fehlt in ${JSON.stringify(kws)}`);
|
||||
});
|
||||
|
||||
test('rejects a same-shaped title with a different number', () => {
|
||||
// The real regression: "777 Main Street" (Release - Topic) was downloaded for DAT ADAM's
|
||||
// "700 Main Street", because only the two longest words (Street, Main) were required.
|
||||
assert.equal(accepts('700 Main Street', '777 Main Street'), false);
|
||||
assert.equal(accepts('700 Main Street', '700 Main Street'), true);
|
||||
});
|
||||
|
||||
test('accepts the abbreviated spelling uploaders use', () => {
|
||||
assert.equal(accepts('700 Main Street', '700 Main st (cr-Version)'), true);
|
||||
assert.equal(accepts('700 Main Street', 'DAT ADAM - 700 Main St [FULL SONG]'), true);
|
||||
});
|
||||
|
||||
test('the abbreviation does not match inside another word', () => {
|
||||
assert.equal(accepts('700 Main Street', '700 Main Stuff'), false);
|
||||
});
|
||||
|
||||
test('titles without numbers keep the previous two-longest-words behaviour', () => {
|
||||
assert.deepEqual(buildTitleKeywords('Bohemian Rhapsody'), ['Bohemian', 'Rhapsody']);
|
||||
assert.equal(accepts('Bohemian Rhapsody', 'Queen - Bohemian Rhapsody (Official Video)'), true);
|
||||
assert.equal(accepts('Bohemian Rhapsody', 'Queen - Another One Bites The Dust'), false);
|
||||
});
|
||||
Reference in new issue
Block a user