VidInfo

Get video information from different APIs.

Download as .zip Download as .tar.gz View on GitHub

VidInfo (v0.2.13)

Install: npm install vidinfo

This project is Unlicensed. In other words, I don't care what you do with it. However, if you make something interesting, I would like to check it out.

Build Status

Current APIs supported:

Supported Formats: JSON, CSV, INI -- XML via xml2json.

archive.org bambuser.com (1) blip.tv dailymotion.com facebook.com (1,3) flickr.com (1) giantbomb.com (1,2) imdb.com (2,3) justin.tv (2) mag.ma (5) on.aol.com themoviedb.org (1) trakt.tv (1,2,3) twitch.tv (2) ustream.tv (2) videolog.tv vimeo.com vzaar.com webcams.travel (1) wistia.com (4) youtube.com

1) API key required. See "bambuser" example at the bottom.
2) This method is BETA.
3) More information available. See "More Information" below.
4) Requires basic auth (username:password). See "wista" example at the bottom.
5) Located in "./apis/obsolete/" due to API changes, removals, or extended down time.
   Just because it's located in obsolete does not mean a replacement hasn't been created.

oEmbed APIs:

For more information on oEmbed visit oEmbed.com.

animoto.com anyclip.com (2) collegehumor.com comedycentral.com (2) coub.com crackle.com (2) dotsub.com funnyordie.com hulu.com jest.com liveleak.com (2) mefeedia.com (2) mixbit.com (2) nfb.ca qik.com revision3.com screenr.com snotr.com (2) socialcam.com (2) ted.com theonion.com (2) trailers.apple.com (1) viddler.com videojug.com vine.co (2) yahoo.com (2)

1) Uses a 3rd party oEmbed API. (https://noembed.com/)
2) Uses a 3rd party oEmbed API. (https://embed.ly/) 
   Requires API key, otherwise you have limited requests.

I will add more (most common) oEmbed APIs from embed.ly eventually.

Embed.ly API:

WARNING: Do NOT enable embedly (./apis/embedly.js) with any other APIs!

Embedly is a HUGE oEmbed provider and as such supports some of the APIs already in use.
Because of this there are conflicts. To generate the embedly.js file, see functions below.
After you run the embedly generator, a new file will be created at: ./apis/embedly.js
Embedly is too massive to display what websites it supports, so you'll have to read embedly.js yourself
or check the embed.ly providers list here: http://embed.ly/embed/features/providers

Services URL: http://api.embed.ly/1/services
API key required, signup here: https://app.embed.ly/signup/

Experimental APIs:

metacafe.com movieclips.com muzu.tv (1) traileraddict.com

1) API key required. See "bambuser" example at the bottom.

NOTE: These now require xml2json. (https://npmjs.org/package/xml2json)

More Information:

(imdb.com)
    IMDB does not have an API so use of a 3rd party API is required.
    Please see http://www.omdbapi.com/ for more information.
(facebook.com)
    Facebook requires an access token to be generated. The generator makes an access token
    that lasts for 60 days. You can revisit the generator to find out when your token will expire.
    I will look for a better method later on, but for now this is how it has to be.
    Generator: http://louist.github.io/VidInfo/accessToken.html
(trakt.tv)
    This API is massive and can return a lot of information. I need to rewrite parts of VidInfo to support this.
    For now, extended summary for Movies and TV shows are supported. (TODO #6)

TODO:

Options:

apikey - The API key, when needed.
basicauth - Your basic auth `username:password`, when needed.
formatter - The formatter to use on your JSON data. See ./examples/youtubecom.js

(detectAll options)
nocheck - Return information on a video more than once if found multiple times. See ./examples/detectAll.js
keys -  An object with API keys.
Example: {keys:{bambuser:'EXAMPLE-KEY',themoviedb:'ANOTHER-KEY'},nocheck:true}

Settings:

format - Use the formatter, true or false.
enabled - Path to enabled API configs. -- Default: ./apis/enabled/
disabled - Path to disabled API configs. -- Default: ./apis/disabled/

Settings usage:

var VidInfo = require('vidinfo')({format:true});

Shortcuts:

Archive.org:                arch, archive, archiveorg
Animoto.com:                ani, animoto, animotocom
Anyclip.com:                aclip, anyclip, anyclipcom
Bambuser.com:               bam, bambuser, bambusercom
Blip.tv:                    blip, bliptv
Collegehumor.com*:          chumor, college, collegehumor, collegehumorcom
Comedycentral.com:          comcen, comedycentral, comedycentralcom
Coub.com:                   coub, coubcom
Crackle.com:                crackle, cracklecom
Dailymotion.com:            dmo, dailymo, dailymotion, dailymotioncom
Dotsub.com:                 dotsub, dotsubcom
Facebook.com:               fbook, fbvideo, facebook, facebookcom
Flickr.com:                 flickr, flickrcom
Funnyordie.com:             ford, funnyor, funnyordie, funnyordiecom
GiantBomb.com:              gbomb, giantbomb, giantbombcom
Hulu.com:                   hulu, hulucom
IMDB.com:                   imdb, imdbcom
Jest.com:                   jest, jestcom
Justin.tv (stream):         jtvs, jstream, justintvstream
Justin.tv (video clip):     jtvc, jclip, justintvclip
Liveleak.com:               lleak, liveleak, liveleakcom
Mag.ma:                     mag, magma
Mefeedia.com:               mefee, mefeedia, mefeediacom
Metacafe.com*:              meta, mcafe, metacafe, metacafecom
MixBit.com:                 mix, mixbit, mixbitcom
Movieclips.com*:            mclips, movieclips, movieclipscom
Muzu.tv*:                   muzu, muzutv
Nfb.ca:                     nfb, nfbca
on.aol.com:                 onaol, onaolcom
Qik.com:                    qik, qikcom
Revision3.com:              revis, revision3, revision3com
Screenr.com:                scrn, screenr, screenercom
Snotr.com:                  snotr, snotrcom
Socialcam.com:              scam, socialcam, socialcamcom
Ted.com:                    ted, tedcom
Themoviedb.org:             tdb, tmdb, themoviedborg
Theonion.com:               onion, theonion, theonioncom
Traileraddict.com*:         tadd, taddict, traileraddict, traileraddictcom
Trailers.apple.com:         tapple, trailersapple, trailersapplecom
Trakt.tv (show/movie):      trakt, trakttv
Twitch.tv (stream):         ttvs, tstream, twitchtvstream
Twitch.tv (video clip):     ttvc, tclip, twitchtvclip
Ustream.tv (stream):        utvs, ustream, ustreamtvstream
Ustream.tv (video clip):    utvc, uclip, ustreamtvclip
Viddler.com:                vidd, viddler, viddlercom
Videojug.com:               vjug, videojug, videojugcom
Videolog.tv:                vlog, videolog, videologtv
Vimeo.com:                  vimeo, vimeocom
Vine.co:                    vine, vineco
Vzaar.com:                  vzaar, vzaarcom
Webcams.travel:             wct, webtra, wtravel, webcamstravel
Wistia.com:                 wistia, wistacom
Yahoo.com:                  yahoo, yvideo, yahoocom
YouTube.com:                yt, youtube, youtubecom

*  See "Experimental APIs" above.

Examples:
    VidInfo.youtube('ZRAr354usf8',console.log);
    VidInfo.yt('ZRAr354usf8',console.log); // YouTube
    VidInfo.dmo('xycczk',console.log); // Dailymotion

Functions:

VidInfo.detect(url[,callback[,options]]) - Parse a URL and create an object used for 'byURL'.
     See ./examples/detect.js

VidInfo.detectAll(string[,callback[,options]]) - Parse a string and return an object with all the IDs.
     Options: keys - The list of keys for APIs that might need them.
              nocheck - Return information on a video more than once if found multiple times.
              Example: {keys:{bambuser:'EXAMPLE-KEY',themoviedb:'ANOTHER-KEY'},nocheck:true}
     See ./examples/detectAll.js

VidInfo.byID(id,api,callback[,options]) - Connects to the (should be) correct API for video information.
     See ./examples/byid.js - Changed from "byid" for standardization.

VidInfo.byURL(url,callback[,options]) - Connects to the (should be) correct API for video information.
     See ./examples/byurl.js - Changed from "byurl" for standardization.

VidInfo.<apiname>(id,callback[,options]) -- Shortcut for 'byID'.
     See ./examples/byapi.js

VidInfo.getAPILocation(apiname) - Get the location of an API config file. The "apiname" is the full name, such as "youtubecom."
     Returns: {is:<true/false>,path:<location>,file:<filename>} -- "is" is in enabled (true) or disabled (false) folder.

VidInfo.enable(apiname[,nomove]) - Enable an API. The "apiname" is the full name, such as "youtubecom."
     NOTE: Moves <apiname> from ./apis/disabled/ to ./apis/enabled/ unless "nomove" is true.

VidInfo.disable(apiname[,nomove]) - Disable an API. The "apiname" is the full name, such as "youtubecom."
     NOTE: Moves <apiname> from ./apis/enabled/ to ./apis/disabled/ unless "nomove" is true.   

VidInfo.genEmbedly([callback[,services url]]) - Generate/update the embedly.js config from the services url.
      Services url: http://api.embed.ly/1/services
      Callback arguments: {message:<string>,location:<string>,success:<boolean>}

Example Usage - Look in "examples" folder for more examples.

var VidInfo = require('vidinfo')({format:true});

// YouTube -- Only return the title and published date, using 'formatter'.
VidInfo.byURL('http://www.youtube.com/watch?v=ZRAr354usf8',console.log,{formatter: function (data,cb) {
       var ret = {};
       if ('$t' in data.entry.title) {
          ret.title = data.entry.title.$t;
          if ('$t' in data.entry.published) {
             ret.published = new Date(Date.parse(data.entry.published.$t));
          }
       };
       cb(ret);
}});

// YouTube by video ID.
VidInfo.byID('ZRAr354usf8','youtube',console.log,{formatter: function (data,cb) {
       var ret = {};
       if ('$t' in data.entry.title) {
          ret.title = data.entry.title.$t;
          if ('$t' in data.entry.published) {
             ret.published = new Date(Date.parse(data.entry.published.$t));
          }
       };
       cb(ret);
}});

// 'byID' shortcut.
VidInfo.vimeo('61969130',console.log);
VidInfo.youtube('ZRAr354usf8',console.log);
VidInfo.yt('ZRAr354usf8',console.log); // YouTube
VidInfo.trakt(["show","under-the-dome"],console.log); // Trakt.tv

// Bambuser (API Key required)
VidInfo.byURL('http://bambuser.com/v/3453034',function (obj) {
       console.log(obj);
},{apikey:'APIKEY'});

// Wista (Basic auth required)
VidInfo.byURL('http://ltdev.wistia.com/medias/piywx9v8rr',function (obj,e) {
   if (!e) {
      console.log('(byapi) wista: '+JSON.stringify(obj)+'\n\n');
    } else {
      console.log('(byapi - ERROR) wista: '+JSON.stringify({error:true,message:obj})+'\n\n');
   }
},{basicauth:'USERNAME:PASSWORD'});

// Facebook (requires access token - http://louist.github.io/VidInfo/accessToken.html)
VidInfo.byURL('https://www.facebook.com/photo.php?v=10101580633888836&set=vb.225034700870481&type=3&theater',function (obj) {
   console.log(JSON.stringify(obj)+'\n\n');
},{apikey:'ACCESS TOKEN'});

// Trakt "byID", must pass an array. ["{:method}","{:id}"] -- Method is show or movie.
// See http://trakt.tv/api-docs/ for more information.
VidInfo.byID(["movie","after-earth-2013"],"trakt",function (obj) {
   console.log(JSON.stringify(obj)+'\n\n');
},{apikey:"APIKEY"})
VidInfo.byID(["show","under-the-dome"],"trakt",function (obj) { 
   console.log(JSON.stringify(obj)+'\n\n');
},{apikey:"APIKEY"})

// 'detect' example. -- Prints video ID and API link in an object.
console.log(VidInfo.detect('http://www.youtube.com/watch?v=ZRAr354usf8'));

// 'detectAll' example. Prints an object with multiple 'detect' objects.
console.log(VidInfo.detectAll('http://www.youtube.com/watch?v=ZRAr354usf8 http://bambuser.com/v/3453034 http://ltdev.wistia.com/medias/piywx9v8rr http://flic.kr/p/e9964e'));