@braccato/provider-blyrics
v0.2.2
Published
Lyrics provider chain with priority and validation
Maintainers
Readme
@braccato/provider-blyrics
Lyrics provider chain with priority ordering and validation. Fetch synchronized lyrics from multiple sources with automatic fallback.
The provider guide walks through setting up a chain with fallback across providers.
Install
npm i @braccato/provider-blyricsUsage
import { ProviderChain, createLRCLibSyncedProvider } from "@braccato/provider-blyrics";
const chain = new ProviderChain();
chain.register("lrclib-synced", createLRCLibSyncedProvider());
const result = await chain.fetchLyrics(
{ song: "Title", artist: "Artist", duration: 240 },
{ signal: abortController.signal }
);Built-in Providers
import {
createBLyricsProvider,
createLRCLibSyncedProvider,
createLRCLibPlainProvider,
createLegatoProvider,
createBinimumProvider,
createPortatoProvider,
createUnisonProvider,
} from "@braccato/provider-blyrics";createUnisonProvider matches on videoId, so pass it on the context when you have one:
const result = await chain.fetchLyrics(
{ song: "Title", artist: "Artist", duration: 240, videoId: "dQw4w9WgXcQ" },
{ signal: abortController.signal }
);Validation
Validate fetched lyrics against a reference to prevent wrong matches:
import { createSimilarityValidator } from "@braccato/provider-blyrics";
const validate = createSimilarityValidator(referenceText, 0.5);
const result = await chain.fetchLyrics(context, { validate });See the full documentation for details.
