scrazzz / redgifs

Simple Python API wrapper for the RedGIFs API
https://redgifs.rtfd.io
MIT License
91 stars 12 forks source link

api.download no longer works #37

Closed xLoyalty closed 2 weeks ago

xLoyalty commented 2 weeks ago

Summary

Using api.download() on a RedGif after retrieving it with api.get_gif() causes an error, and will not download it.

Reproduction Steps

something as simple as this is not working as of right now:

response = await api.get_gif(video_id)
await api.download(response.urls.hd)

it gives a whole bunch of errors:

Task exception was never retrieved
future: <Task finished name='Task-22' coro=<check_new_posts() done, defined at G:\*******\*******\Bot\bot.py:1292> exception=TypeError('"https://api.redgifs.com/v2/embed/discord?name=SmoothSpectacularHydra.mp4" is not a valid RedGifs URL')>
Traceback (most recent call last):
  File "G:\*******\*******\Bot\bot.py", line 1324, in check_new_posts
    await api.download(response.urls.embed_url, "RefreshingPorn.mp4")
  File "C:\Python310\lib\site-packages\redgifs\aio.py", line 388, in download
    return (await self.http.download(url, fp))
  File "C:\Python310\lib\site-packages\redgifs\http.py", line 449, in download
    raise TypeError(f'"{strip_ip(str_url)}" is not a valid RedGifs URL')
TypeError: "https://api.redgifs.com/v2/embed/discord?name=SmoothSpectacularHydra.mp4" is not a valid RedGifs URL
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001D275A17C40>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000001D275AF0040>, 16834.375)]']
connector: <aiohttp.connector.TCPConnector object at 0x000001D275A16DD0>
xLoyalty commented 2 weeks ago

also, your discord link on the readme is invalid (https://discord.gg/yNsUTuXvzn)

scrazzz commented 2 weeks ago

I’m able to access the URL in your error from my browser normally so I don’t know what the issue is. Are you sure this is the full error? If not, then you will need to provide the full error traceback so that I can debug this issue. This error could also be related to #36 possibly and I’m working on a fix locally, just needs some more testing until I can push the updated code.

also, your discord link on the readme is invalid (https://discord.gg/yNsUTuXvzn)

Thanks, I’ve updated it: https://discord.gg/NtAJMCcTd4

xLoyalty commented 2 weeks ago

yeah thats the weird thing, the links are fully valid but i just keep getting this error (which is the only output on my terminal):

Task exception was never retrieved
future: <Task finished name='Task-22' coro=<check_new_posts() done, defined at G:\*******\*******\Bot\bot.py:1292> exception=TypeError('"https://files.redgifs.com/PotableChubbyPitbull.mp4" is not a valid RedGifs URL')>
Traceback (most recent call last):
  File "G:\*******\*******\Bot\bot.py", line 1324, in check_new_posts
    await api.download(response.urls.hd, "RefreshingPorn.mp4")
  File "C:\Python310\lib\site-packages\redgifs\aio.py", line 388, in download
    return (await self.http.download(url, fp))
  File "C:\Python310\lib\site-packages\redgifs\http.py", line 443, in download
    raise TypeError(f'"{strip_ip(str_url)}" is not a valid RedGifs URL')
TypeError: "https://files.redgifs.com/PotableChubbyPitbull.mp4" is not a valid RedGifs URL
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001B6FE1B5A20>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000001B6FE298160>, 23261.515)]']
connector: <aiohttp.connector.TCPConnector object at 0x000001B6FE1B5A50>

if i print my response.urls i get valid links so i'm unsure as to what's causing the issue, but im guessing it is related to that PR.

URL(sd='https://files.redgifs.com/PotableChubbyPitbull-mobile.mp4', hd='https://files.redgifs.com/PotableChubbyPitbull.mp4', poster='https://files.redgifs.com/PotableChubbyPitbull-poster.jpg', thumbnail='https://files.redgifs.com/PotableChubbyPitbull-mobile.jpg', vthumbnail='https://files.redgifs.com/PotableChubbyPitbull-mobile.mp4', web_url='https://redgifs.com/watch/potablechubbypitbull', file_url='https://api.redgifs.com/v2/gifs/potablechubbypitbull/files/PotableChubbyPitbull.mp4', embed_url='https://api.redgifs.com/v2/embed/discord?name=PotableChubbyPitbull.mp4')
scrazzz commented 2 weeks ago

I have pushed an update right now on GitHub. Can you update and test again? To update, run this in your console:

python3 -m pip install --upgrade git+https://github.com/scrazzz/redgifs
xLoyalty commented 2 weeks ago

new update fixes it, thanks!