Folgekorrektur zu 02b5905: "… - 2020 Remaster" steht auf der Veroeffentlichung,
aber nie im YouTube-Titel — als Pflicht-Keyword haette die Zahl den richtigen
Upload abgelehnt. Jahreszahlen neben einem Qualifier (remaster/version/edition/
anniversary/mono/stereo) fallen daher wieder raus; ein Titel, der selbst eine
Jahreszahl ist ("1999", "Berlin 2020"), behaelt sie. Gegen 29 Beispieltitel
gemessen verhalten sich 24 exakt wie vorher.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
48 lines
2.3 KiB
JavaScript
48 lines
2.3 KiB
JavaScript
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);
|
|
});
|
|
|
|
test('a remaster year is not required — YouTube titles never carry it', () => {
|
|
// "… - 2020 Remaster" steht auf der Veröffentlichung, der Upload heißt schlicht
|
|
// "Take Me Home, Country Roads". Vor dieser Ausnahme hätte die 2020 ihn abgelehnt.
|
|
assert.equal(accepts('Take Me Home, Country Roads - 2020 Remaster',
|
|
'John Denver - Take Me Home, Country Roads'), true);
|
|
});
|
|
|
|
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);
|
|
});
|