Giter Club home page Giter Club logo

gifs-api-node's Introduction

gifs-api

Node.js API for gifs.com's public-api for importing media.

Accepted media types:

  • gif -> image/gif.
  • mp4 -> video/mp4.
  • webm -> video/wemb.

Routes:

  • /import, takes in a source URL, sends it the API endpoint then imports it into gifs.com's API.
  • /upload, takes a file/stream/binary-data in the form of a multipart-form, sends it to the API endpoint then makes the equivalent files.

Sample usage in code:

  • Import any media, mp4, gif, webm
const gifs = require('gifs-api');

const urls = ['https://giant.gfycat.com/ClutteredSevereCur.gif', 'https://fat.gfycat.com/JovialPerkyArmyant.webm', 'https://pbs.twimg.com/tweet_video/Ca0ztmfWIAAi-UX.mp4'];
urls.forEach(function(url) {
  gifs.import(url, function(status, response) {
    console.log('url', url, status, response);
  });
});

// Alternatively
urls.forEach(function(url) {
  gifs.import({source: url, attribution: {user: 'nbcsnl', site: 'twitter'}, title: '40th Anniversary SNL'}, function(status, response) {
    console.log('url', url, status, response);
  });
});
  • To restrict importing, use:
  • gifs.importMP4.
  • gifs.importWEBM.
  • gifs.importGIF.
  • Upload any accepted media: mp4, gif, webm.
const fs   = require('fs');
const gifs = require('gifs-api');
const glob = require('glob');

glob('**/*.mp4', function(err, mp4Matches) {
  if (err)
    throw err;

  mp4Matches.forEach(function(mp4Match) {
    fs.readFile(mp4Match, function(err, stream) {
      if (err)
	throw err;

      var form = {
	file: stream,
	title: mp4Match,
	attribution_url: 'https://mysite.com',
	attribution_user: 'yourself',
	attribution_name: 'mysite',
      };

      gifs.upload(form, function(status, response) {
	console.log('mp4Match', mp4Match, status, response);
      });
  });
});

For stricter uploading, use:

  • gifs.uploadMP4.
  • gifs.uploadWEBM.
  • gifs.uploadGIF.

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.