mrsrmn / RedditEasy

RedditEasy is a rapidly-fast API wrapper for getting posts using the Reddit JSON API with both sync and async options
https://redditeasy.readthedocs.io/
GNU General Public License v3.0
10 stars 2 forks source link

Async Redditeasy doesn't work but Sync Redditeasy does #1

Closed BiasedKiwi closed 2 years ago

BiasedKiwi commented 2 years ago

just like the title says

Traceback:

Ignoring exception in command meme:
Traceback (most recent call last):
  File "/home/alexandre/.local/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 168, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/alexandre/Projects/Bots/Hadum/src/extensions/reddit.py", line 30, in meme
    meme = await post.get_post(subreddit=subreddit)
  File "/home/alexandre/.local/lib/python3.8/site-packages/redditeasy/subreddit.py", line 49, in get_post
    return await get_async_post(self, rtype="hot", rfor=subreddit, slash="r")
  File "/home/alexandre/.local/lib/python3.8/site-packages/redditeasy/base.py", line 280, in get_async_post
    meme = await async_request(headers=headers, client_auth=client_auth, rtype=rtype, rfor=rfor, slash=slash)
  File "/home/alexandre/.local/lib/python3.8/site-packages/redditeasy/base.py", line 20, in async_request
    content = await r.json()
  File "/home/alexandre/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1097, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://www.reddit.com/r/dankmemes/hot.json')

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

Traceback (most recent call last):
  File "/home/alexandre/.local/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 995, in invoke
    await ctx.command.invoke(ctx)
  File "/home/alexandre/.local/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 895, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/alexandre/.local/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 177, in wrapped
    raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://www.reddit.com/r/dankmemes/hot.json')

Aiohttp version: 3.7.4.post0 Redditeasy version: 3.6.3

mrsrmn commented 2 years ago

@shadawcraw So, turns out this wasnt a problem on the library. I looked at the content of the HTML page (text/html) the API returned and looks like it's an issue on your side. This is how the HTML looks like image

You can probably fix this by regenerating your Reddit credentials.

BiasedKiwi commented 2 years ago

Alright thanks. I'll try this out as soon as possible. This is probably the answer because Praw returns the same error.