LapisMirror icon indicating copy to clipboard operation
LapisMirror copied to clipboard

Add Twitter GIF Support

Open kupiakos opened this issue 8 years ago • 3 comments

Here

kupiakos avatar Mar 21 '16 22:03 kupiakos

The issue with Twitter gifs is that they're encoded in .mp4 files, not .gifs. To upload them, it might be better to use gfycat.com or vid.me to properly mirror them.

spiral6 avatar Jul 02 '16 23:07 spiral6

Since Lapis Mirror already supports vid.me, it shouldn't be a huge problem. I'd like to avoid using gfycat as they specifically mention the case of a Reddit bot.

kupiakos avatar Jul 04 '16 02:07 kupiakos

We can use vid.me to mirror. Now, to get the URL from the tweet, this snippet demonstrates how to do so.

if tweet.extended_entities['media'][0]['type'] == 'animated_gif':
    video_info = tweet.extended_entities['media'][0]['video_info']
    print(video_info['variants'][0]['url'])

The variants array will always be a size of one. We would have to do this for every medium in the extended_entities array, which is already setup in twitter.py. So, that's it. Right now twitter.py only works if the tweet is of type 'photo', so there will be some logic added to it to ensure that Lapis can mirror .gifs from Twitter as well.

spiral6 avatar Feb 09 '17 20:02 spiral6