Version 2.1.0 - Update UI
This commit is contained in:
18 files changed
+3508
-330
No files matched your search
@@ -0,0 +1,90 @@
|
||||
// Test réseau de backend/src/lyrics/Lyrics.js contre LRCLIB réel (node lyrics.live.js) : affiche les résultats
|
||||
const { check, done, req } = require("./_setup");
|
||||
const L = req("src/lyrics/Lyrics.js");
|
||||
|
||||
// Formes rencontrées en vrai : titres YouTube bruts, chaînes VEVO / Topic, morceaux Spotify propres
|
||||
const SONGS = [
|
||||
{ type: "youtube", id: "FGBhQbmPwH8", title: "Daft Punk - One More Time (Official Video)", author: "Daft Punk", duration: 320, expectSynced: true },
|
||||
{ type: "youtube", id: "dQw4w9WgXcQ", title: "Rick Astley - Never Gonna Give You Up (Official Music Video)", author: "Rick Astley", duration: 213, expectSynced: true },
|
||||
{ type: "youtube", id: "spotify-papaoutai", title: "Papaoutai", author: "Stromae", duration: 232, expectSynced: true },
|
||||
{ type: "youtube", id: "fJ9rUzIMcZQ", title: "Queen – Bohemian Rhapsody (Official Video Remastered)", author: "Queen Official", duration: 360 },
|
||||
{ type: "youtube", id: "topic-test", title: "Get Lucky (feat. Pharrell Williams and Nile Rodgers)", author: "Daft Punk - Topic", duration: 369 },
|
||||
{ type: "youtube", id: "nope", title: "zzqx introuvable 8472 kq", author: "Personne", duration: 100, expectMiss: true },
|
||||
];
|
||||
|
||||
function preview(result) {
|
||||
if (!result.ok) return `échec ${result.error}`;
|
||||
const first = result.synced ? result.lines.find(l => l.text) : null;
|
||||
return `${result.source} · ${result.instrumental ? "instrumental" : result.synced ? `synchronisées (${result.lines.length} lignes, 1re à ${(first.t / 1000).toFixed(2)} s : « ${first.text} »)` : "texte seul"}`
|
||||
+ ` · match ${result.match.artist} - ${result.match.track} (${result.match.album || "?"}, ${result.match.duration} s, id ${result.match.id ?? "-"})`;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
for (const song of SONGS) {
|
||||
const t = Date.now();
|
||||
const result = await L.getLyricsForSong(song);
|
||||
console.log(`\n${song.title} / ${song.author}\n requête : ${JSON.stringify(L.guessQuery(song))}\n ${preview(result)} [${Date.now() - t} ms]`);
|
||||
if (song.expectMiss) check("introuvable → NOT_FOUND", !result.ok && result.error === "NOT_FOUND", result);
|
||||
else check(`trouvé : ${song.title}`, result.ok && !!(result.plain || result.instrumental), result.error);
|
||||
if (song.expectSynced) {
|
||||
check(`synchronisées : ${song.title}`, result.ok && result.synced);
|
||||
// Horodatages exploitables : croissants, en ms, dans la durée du morceau
|
||||
const lines = result.ok && Array.isArray(result.lines) ? result.lines : [];
|
||||
const texts = lines.filter(l => l.text);
|
||||
const sorted = lines.every((l, i) => Number.isInteger(l.t) && l.t >= 0 && (i === 0 || l.t >= lines[i - 1].t));
|
||||
const last = lines.length ? lines[lines.length - 1].t : 0;
|
||||
check(`horodatages croissants (${texts.length} lignes)`, texts.length >= 10 && sorted && last > 30000 && last <= (song.duration + 15) * 1000, { lines: lines.length, last });
|
||||
check("User-Agent identifiant envoyé", /^Subsonics-Chopin\/\S+ \(https?:\/\//.test(L.USER_AGENT));
|
||||
}
|
||||
check("songKey", result.songKey === `${song.type}:${song.id}`);
|
||||
}
|
||||
|
||||
const t = Date.now();
|
||||
await L.getLyricsForSong(SONGS[0]);
|
||||
check("2e appel servi par le cache", Date.now() - t < 50);
|
||||
|
||||
const search = await L.searchCandidates("daft punk one more time");
|
||||
console.log(`\nsearchCandidates : ${search.ok ? search.results.length + " résultats" : search.error}`);
|
||||
if (search.ok) for (const c of search.results.slice(0, 5)) console.log(` #${c.id} ${c.artist} - ${c.track} (${c.album}, ${c.duration} s${c.synced ? ", synchro" : ""})`);
|
||||
check("searchCandidates ok", search.ok && search.results.length > 0);
|
||||
|
||||
if (search.ok && search.results.length) {
|
||||
const byId = await L.getById(search.results[0].id);
|
||||
console.log(`getById(${search.results[0].id}) : ${preview(byId)}`);
|
||||
check("getById ok", byId.ok);
|
||||
}
|
||||
|
||||
const legacy = await L.getLyrics("Daft Punk - One More Time");
|
||||
check("getLyrics (compat) renvoie du texte", typeof legacy === "string" && legacy.length > 20);
|
||||
|
||||
// Repli : LRCLIB rendu injoignable, Deezer + lyrics.ovh réels
|
||||
console.log("\nRepli lyrics.ovh (LRCLIB simulé en panne)");
|
||||
const realFetch = globalThis.fetch;
|
||||
const hosts = [];
|
||||
globalThis.fetch = async (input, options) => {
|
||||
const host = new URL(String(input)).host;
|
||||
hosts.push(host);
|
||||
if (host === "lrclib.net") throw new TypeError("fetch failed");
|
||||
return realFetch(input, options);
|
||||
};
|
||||
try {
|
||||
L.clearCache();
|
||||
const t0 = Date.now();
|
||||
const fallback = await L.getLyricsForSong({ type: "youtube", id: "ovh-test", title: "Coldplay - Yellow (Official Video)", author: "Coldplay", duration: 269 });
|
||||
console.log(` ${fallback.ok ? preview(fallback) : "échec " + fallback.error} [${Date.now() - t0} ms] · hôtes : ${[...new Set(hosts)].join(", ")}`);
|
||||
check("repli tenté (Deezer puis lyrics.ovh)", hosts.includes("api.deezer.com") && hosts.includes("api.lyrics.ovh"), [...new Set(hosts)]);
|
||||
if (fallback.ok) {
|
||||
check("repli : texte seul depuis lyrics.ovh", fallback.source === "lyrics.ovh" && !fallback.synced && fallback.lines === null && fallback.plain.length > 100);
|
||||
} else {
|
||||
// lyrics.ovh est souvent en panne : signalé sans faire échouer le test
|
||||
console.log(` AVERTISSEMENT : lyrics.ovh n'a rien renvoyé (${fallback.error}), le repli n'a pas pu être vérifié de bout en bout`);
|
||||
check("repli en panne → UNAVAILABLE (LRCLIB injoignable)", fallback.error === "UNAVAILABLE");
|
||||
}
|
||||
} finally {
|
||||
globalThis.fetch = realFetch;
|
||||
}
|
||||
done();
|
||||
})().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in new issue
Block a user