Giter VIP home page Giter VIP logo

Comments (5)

wasdennnoch avatar wasdennnoch commented on June 17, 2024 1

I think you are talking about the embedded preview here. It's true that Reddit already converts the gif by itself and embeds it so I could link that one; but giphy also converts it to mp4 and host it automatically. Currently I use the giphy mp4 (there is no unneccessray re-encode, both giphy and reddit convert the gif, there is no additional video-to-gif or video-to-video conversion).

Since I don't use the preview link but the actual source link (which links to media.giphy.com) I also don't have to check for headers (and I already know the redditmedia links are mp4s due to the &fm=mp4 in the URL).

So in the end it seems to be that the reddit preview is indeed even smaller than giphys mp4 version but I don't know it that's always the case. The main problem here is that the API doesn't always return the preview links (this post is a perfect example) so the only link the bot knows of is the original giphy gif link. I'll have to see if that's always the case, if it sometimes provides a preview I'll also have a look if it's always smaller than giphys mp4 version.

Thanks for your report and investigations, we'll have to see though if it has reliable results.

from reddit-anti-gif-bot.

rogermparent avatar rogermparent commented on June 17, 2024

I'm not super familiar with node, but I think the proper answer to this problem lies in running a HEAD request on the file in question and checking the Content-Type before deciding to convert.
For example, on this file that ends in .gif but is actually an mp4 gifv:

~ curl --head https://g.redditmedia.com/CsL-zE1BljfD6v8JdkWKDSrah_V7uPfP-FK2CmYBgp0.gif\?w\=480\&fm\=mp4\&mp4-fragmented\=false\&s\=c846479a543a2687f1305fe2e9082208 
HTTP/1.1 200 OK
Cache-Control: max-age=315360000
Last-Modified: Fri, 21 Apr 2017 17:14:46 GMT
Server: imgix-fe
--> Content-Type: video/mp4
X-Imgix-Request-ID: 7f40bc683e0ec5e4c47f074b3daec509bd9fd1b7
X-Content-Type-Options: nosniff
Fastly-Debug-Digest: 2fcce3287ea07016c334bf917093bea9fba8c7d24f360494cdab9387c9c6bae8
Content-Length: 1104675
Accept-Ranges: bytes
Date: Sat, 22 Apr 2017 05:09:36 GMT
Via: 1.1 varnish
Age: 42888
Connection: keep-alive
X-Served-By: cache-lax8646-LAX, cache-bos8235-BOS
X-Cache: HIT, HIT
X-Cache-Hits: 1, 1
X-Timer: S1492837777.855722,VS0,VE1

Maybe there's a Node curl library? Now that I think about it, that's so common that there has to be.

The Content-Type for "true" gifs is "image/gif", so I think if we find a way to check the content type it'll be safe to only convert gifs with that content type, anything else is probably a gifv. This way we'll never have to deal with URL shenanigans even on unknown sites.

from reddit-anti-gif-bot.

rogermparent avatar rogermparent commented on June 17, 2024

Ayy I found a stackoverflow answer pertaining to getting head requests, no external libraries needed (I think?)!
http://stackoverflow.com/questions/5922842/getting-http-headers-with-node-js

I might take a whack at it tomorrow if I have time, but you know your code best so you'll probably know the best area to implement this info.

from reddit-anti-gif-bot.

rogermparent avatar rogermparent commented on June 17, 2024

You're right, I misunderstood the difference and thought the preview and source are the same- I never knew Reddit does its own conversions! That's what I get for reporting issues late at night!

from reddit-anti-gif-bot.

wasdennnoch avatar wasdennnoch commented on June 17, 2024

I'll close this since it's not really an issue, even though the destop site has a preview mobile apps don't and use the provided gif link.

from reddit-anti-gif-bot.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.