michael-lazar / rtv

Browse Reddit from your terminal
MIT License
4.64k stars 274 forks source link

gfycat links not working after change in api #641

Closed thy6 closed 5 years ago

thy6 commented 5 years ago

It's been a few months since gfycat is broken in rtv because they changed their api and the cajax link in rtv's mime_parsers no longer works (in rtv 1.24.0).

Sorry, I don't know any python, but I tried to fix this issue and it seems to be working so I'm sharing this here.

To fix the issue, I changed the lines 113 and 114 in the file ~/.local/lib/python3.6/site-packages/rtv/mime_parsers.py

from

    parts = url.replace('gifs/detail/', '').split('/')
    api_url = '/'.join(parts[:-1] + ['cajax', 'get'] + parts[-1:])

to

    parts = url.replace('gifs/detail/', '').replace('www.','').replace('gfycat.','api.gfycat.').split('/')
    api_url = '/'.join(parts[:-1] + ['v1', 'gfycats'] + parts[-1:])

This may not be the best way of doing it, but gfycat links are now opening according to my .mailcap (instead of opening in the browser as they did while it was broken).

Thanks.

michael-lazar commented 5 years ago

Thanks for posting! This happens every once in a while, I'll make sure this fix gets into the next release.