pear-devs/pear-desktop · error · Error

Failed to extract lyrics from page.

Error message

Failed to extract lyrics from page.

What it means

After picking the closest Megalobiz search result, the provider fetches that result page and looks for an element matching span[id^="lrc_"][id$="_lyrics"] containing the raw LRC lyrics. If the element is missing (selector returns nothing), it throws 'Failed to extract lyrics from page.'

Source

Thrown at src/plugins/synced-lyrics/providers/Megalobiz.ts:93

    const sortedResults = searchResults.sort(
      ({ duration: durationA }, { duration: durationB }) => {
        const left = Math.abs(durationA - songDuration);
        const right = Math.abs(durationB - songDuration);

        return left - right;
      },
    );

    const closestResult = sortedResults[0];
    if (!closestResult) return null;
    if (Math.abs(closestResult.duration - songDuration) > 15) {
      return null;
    }

    const html = await fetch(`${this.baseUrl}${closestResult.href}`).then((r) => r.text());
    const lyricsDoc = this.domParser.parseFromString(html, 'text/html');
    const raw = lyricsDoc.querySelector('span[id^="lrc_"][id$="_lyrics"]')?.textContent;
    if (!raw) throw new Error('Failed to extract lyrics from page.');

    const lyrics = LRC.parse(raw);

    return {
      title: closestResult.title,
      artists: closestResult.artists,
      lines: lyrics.lines.map((l) => ({ ...l, status: 'upcoming' })),
    };
  }
}

interface MegalobizSearchResult {
  title: string;
  artists: string[];
  href: string;
  duration: number;
}

View on GitHub (pinned to 1e2aac5706)

Solutions

  1. Update the synced-lyrics plugin for current Megalobiz markup
  2. Fall back to other providers when this throws
  3. Degrade to 'no synced lyrics' in the UI instead of erroring
  4. Verify the track's Megalobiz page in a browser to see whether LRC content exists

Example fix

// before
const r = await megalobiz.search(info);

// after
try { return await megalobiz.search(info); }
catch (e) { if (!/extract lyrics from page/.test(e.message)) throw e; return await lrclib.search(info); }
Defensive patterns

Strategy: fallback

Try / catch

try { return await megalobiz.search(info); } catch (e) { if (!/extract lyrics from page/.test(e.message)) throw e; return await lrclib.search(info); }

Prevention

When it happens

Trigger: Megalobiz changing their result-page markup (renaming the lrc_ span id pattern); result pages without synced (LRC) lyrics — only plain lyrics; pages blocked by bot checks serving different HTML; parse mismatches after site redesigns.

Common situations: Site redesigns breaking the CSS selector (classic scraper breakage); tracks that have lyrics but not time-synced LRC content; ad/anti-bot interstitials replacing the real page.

Related errors


AI-assisted analysis of pear-devs/pear-desktop@1e2aac5706 (2026-08-27). Data as JSON: /api/errors/cc9da744ab9c4f0d. Report an issue: GitHub.