Remove unnecessary sections from Genius lyrics (#1154)

* remove unnecessary sections in genius lyrics

* made variable names camelCase

* used title instead of full title
This commit is contained in:
angelolz 2025-10-22 19:28:49 -06:00 committed by GitHub
parent ce1d37479c
commit 947cad451c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -109,8 +109,11 @@ export async function getLyricsBySongId(url: string): Promise<null | string> {
if (lyricsDiv.length > 0) return lyricsDiv.text().trim();
const lyricSections = $('div[class^=Lyrics__Container]')
.map((_, e) => $(e).text())
const lyricSections = $('div[data-lyrics-container="true"]')
.map((_, e) => {
$(e).find('[data-exclude-from-selection="true"]').remove();
return $(e).text();
})
.toArray()
.join('\n');
return lyricSections;
@ -204,7 +207,7 @@ async function getSongId(
return {
artist: hit.artist_names,
id: hit.url,
name: hit.full_title,
name: hit.title,
source: LyricSource.GENIUS,
};
}