Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Fix with Genius UI update #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix with Genius UI update #17

wants to merge 2 commits into from

Conversation

pfgithub
Copy link

The lyrics are now shown in two places in the html, once in the thing with the class .lyrics and once for react preloading or something in a script tag. I would have used the one in the .lyrics div but cheerio doesn't seem to have anything similar to html .innerText that gets the text content including <br /> tags as newlines. There might be an easier way to do this than what I've done.

@scf4
Copy link
Owner

scf4 commented Mar 19, 2022

Hi I haven't had any issue using the package to fetch lyrics (last used it ~2 months ago). Could you clarify the issue this PR fixes?

@pfgithub
Copy link
Author

pfgithub commented Mar 19, 2022

Tested again - lyrics fetching is not working at all for me and just returning an empty string.

const {lyrics} = await lyricist.song(song_id, {fetchLyrics: true});
console.log(lyrics); // empty string

Applying this patch makes it work again.

If I go to a lyrics page on the genius website, document.querySelectorAll(".lyrics") returns an empty array

image

It might be possible that this update is not completely rolled out or there's some difference on your system making it return the old version of the page?

This PR is much more complex than it needs to be to fix this issue, ideally it could just be document.querySelector("#lyrics-root").innerText but cheerio doesn't support innerText and textContent can't be used because it doesn't include br tags. It could likely be significantly simplified by looping over the dom elements rather than trying to parse text out of the react preload script. Also, if some people are seeing a different page, it should support both .lyrics and #lyrics-root so this doesn't break anything for people.

@scf4
Copy link
Owner

scf4 commented Mar 19, 2022

Oh I'm sorry. I just checked the project repo where it worked fine and it was actually Nov 4-5, so a bit more than the 2 months I remembered. Running the code now returns an empty string for lyrics... it must have been a slow rollout(?).

Thank you for the PR, I'll take a look at the new layout and see if it can be done a simpler way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants