zyrouge / node-genius-lyrics

Simple lyrics fetcher that uses Genius. Also has official API implementations.
https://genius-lyrics.js.org
MIT License
61 stars 12 forks source link

[Bug] .lyrics() sometimes works but more often fails with no result found #17

Closed tatsumara closed 2 years ago

tatsumara commented 2 years ago

I believe this issue is related to 403 errors, as I've seen that mentioned elsewhere and had that exact issue with another library

zyrouge commented 2 years ago

I tried as much as I can to get a 403 code, but it seems like I cannot. Does this occur only on certain environments or do you have any steps to can reproduce this? I tested on both node v14.16.0, v15.11.0 and v16.8.0. Only the ci workflow seems to fail.

tatsumara commented 2 years ago

Unfortunately I haven't at all managed to reliably reproduce this, but it seems to happen more on my offsite server running ubuntu than on my main desktop. They're both using node v16.9.1 though. I can confirm this isn't just a one-off issue, as I just had it happen again. The first time it works just fine, but the second time running it with the exact same parameters throws an error: Error: No result was found

The relevant bits of code I'm using is this:

const results = await geniusClient.search(args.join(' '));
const lyrics = await results[0].lyrics();
MrPropre commented 2 years ago

I have exactly the same behavior with node v16.7.0 on my desktop

zyrouge commented 2 years ago

I researched a bit and it seems like different responses are send (200 fetched, 302 cached and some preloaded thing), I'll update the scraper within a couple of days.

tatsumara commented 2 years ago

Any update on this? I would take a look myself but I'm not all that good with JS/TS

MrPropre commented 2 years ago

@zyrouge This issue is specific to lyric extraction. The error occurs only here : https://github.com/DevSnowflake/genius-lyrics/blob/e8169053dc7faf2f651b2e49daa7b0f0b1297eef/lib/Songs/Song.ts#L63

Maybe you should take a look at this library which use a different method to extract lyrics. Using it worked for me.

tatsumara commented 2 years ago

Still doesn't work, same 403 error

zyrouge commented 2 years ago

Still doesn't work, same 403 error

403 cannot be bypassed without using proxy. Genius.com blocks certain IP addresses so unless use a vpn or a proxy it's won't work.