michael-lazar / rtv

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

gfycat mp4 support. #609

Closed mac1202 closed 6 years ago

mac1202 commented 6 years ago

Hi, in the mime_parsers.py you choose webm as default format for gfycat, but gfycat provide better and smaller file in mp4 format. For example here the output of youtube-dl --list-format on a gfycat link

webm         webm       1920x1080  56.50MiB
mp4          mp4        1920x1080  4.77MiB (best)

By modifying the mime_parsers.py I get the mp4 as default format, here's the modifications

--- mime_parsers.py 2018-09-23 16:51:33.165590261 +0200
+++ /usr/lib/python3.7/site-packages/rtv/mime_parsers.py    2018-09-23 16:49:21.805756332 +0200
@@ -113,8 +113,8 @@
         parts = url.replace('gifs/detail/', '').split('/')
         api_url = '/'.join(parts[:-1] + ['cajax', 'get'] + parts[-1:])
         resp = requests.get(api_url)
-        image_url = resp.json()['gfyItem']['webmUrl']
-        return image_url, 'video/webm'
+        image_url = resp.json()['gfyItem']['mp4Url']
+        return image_url, 'video/mp4'

 class YoutubeMIMEParser(BaseMIMEParser):

Would be nice if you can merge the modification into rtv.

michael-lazar commented 6 years ago

Looks good to me, feel free to make a pull request!

mac1202 commented 6 years ago

Just make a pull request. First time doing that I hope I did it properly :)

michael-lazar commented 6 years ago

Merged in https://github.com/michael-lazar/rtv/pull/610