kaogurai / cogs

Red cogs made for kaogurai
MIT License
13 stars 9 forks source link

[SmartLyrics] Command raised an exception: Exception: Could not get search results. #32

Open cool-aid-man opened 1 month ago

cool-aid-man commented 1 month ago

Hey Ryan,

Getting Command raised an exception: Exception: Could not get search results. from ly.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1366, in invoke await ctx.command.invoke(ctx) File "/home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1029, in invoke await injected(*ctx.args, **ctx.kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 244, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Exception: Could not get search results.



Hope you get some time to look into it
Thanks
Ryan5453 commented 1 month ago

What do you mean "Client Access Token"? The cog doesn't do any authentication.

Are you sure your IP didn't just get banned somehow? The cog still works for me

cool-aid-man commented 1 month ago

What do you mean "Client Access Token"? The cog doesn't do any authentication.

Yes, the cog doesn't. I meant that since it's throwing me the error, I wanted to check if the API is working or not (for debugging purposes, basically)—hence, I used another service, Postman, to check whether the API is up or down (and that service requires a Token, which you can generate via Genius). Sorry, I could have been more clearer.

Are you sure your IP didn't just get banned somehow? The cog still works for me

Oh god! How do I check it? In our use case, the cog barely gets used 2-3 times a day, sometimes even less or none. So unless it's related to that YouTube ban (where YouTube banned a large number of ASNs—the reason why audio is unusable/broken for many many users - including me), I don't see any viable reason why my IP could get banned from using the cog alone 😥! Unless, of course, I'm missing something else.

A bit more info (if it helps): Since the YouTube ban, I had unloaded the Audio cog but the smartlyrics cog was working fine until it stopped and started erroring a few days ago.

cool-aid-man commented 1 month ago

Update

Ryan, looks like it is an IP ban.

Tried with this:

<p>eval
headers = {"X-Genius-iOS-Version": "6.7.0",
                "X-Genius-Logged-Out": "true",
                "User-Agent": "Genius/1015 CFNetwork/1390 Darwin/22.0.0",
}
async with aiohttp.ClientSession(headers=headers) as session:
    parms = {"q": "hello",}
    async with session.get('https://api.genius.com/search/multi', params=parms) as resp:
        print(resp.status)
        j = await resp.json()
        print(j)

And it returned 403 👇 (Looks like the YouTube ban did effect the cog)

403
Traceback (most recent call last):
  File "<eval command - snippet #8>", line 9, in func
    j = await resp.json()
        ^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/redenv/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://api.genius.com/search/multi?q=hello')

I suppose there's very little to do here but I still wanna ask -

(We actually love the cog so much and honestly, this is the only cog that has this ability to fetch the lyrics which is why asking this question, so if there's anything you could do would really be appreciated)

sravan1946 commented 1 month ago

Update

Ryan, looks like it is an IP ban.

Tried with this:

<p>eval
headers = {"X-Genius-iOS-Version": "6.7.0",
                "X-Genius-Logged-Out": "true",
                "User-Agent": "Genius/1015 CFNetwork/1390 Darwin/22.0.0",
}
async with aiohttp.ClientSession(headers=headers) as session:
    parms = {"q": "hello",}
    async with session.get('https://api.genius.com/search/multi', params=parms) as resp:
        print(resp.status)
        j = await resp.json()
        print(j)

And it returned 403 👇 (Looks like the YouTube ban did effect the cog)

PS. this was the actuall responce we got back: https://gist.github.com/cool-aid-man/ab3f304871ece051914edaef80142fe3

Ryan5453 commented 1 month ago

This doesn't have anything to do with a YouTube ban - it's just Cloudflare blocking your requests

Ryan5453 commented 1 month ago

I just changed the headers used to contact Genius, let me know if it changes anything

sravan1946 commented 1 month ago

Its still not able to fetch results

Ryan5453 commented 1 month ago

This isn't really a thing that I can fix it seems - I'm not sure exactly how but Genius blocked you via Cloudflare. If you can get a new IP address it should fix it

sravan1946 commented 1 month ago

we did some testing and making request using curl_cffi seems to work image

Ryan5453 commented 1 month ago

Is this running on the same server though?

cool-aid-man commented 1 month ago

Is this running on the same server though?

Yep, that's on the same server that is getting blocked otherwise without the lib