embedit
You can get any page's embed result as json of requested url with this library.
Installation
$ npm install embedit
API
We have one method.
embedit(url,callback)
You can get embed code of given url. Has two parameters.
- url : Url address
- callback(error, result) : Has two parameters. If expect any error, error object return. Result object inherit embed object of given url.
var embedit = require('embedit');
var url = "http://www.youtube.com/watch?v=Fo37BlBCFfk";
embedit(url,function(error, result){
if(error){
// error message
}else{
// result
/*
{
"video":{
"url":"http://www.youtube.com/v/Fo37BlBCFfk?autohide=1&version=3",
"type":"application/x-shockwave-flash",
"width":"1280",
"height":"720"
},
"images":[
{
src:"https://i.ytimg.com/vi/Fo37BlBCFfk/maxresdefault.jpg",
width:'1280',
height:'720'
}
],
"title":"Official Apple iPad Mini Trailer",
"description":"iPad Mini by Apple The full iPad experiance. There`s less of it, but no less to it. Everything you love about iPad — the beautiful screen, fast and fluid per...",
"sitename":"YouTube",
"url":"http://www.youtube.com/watch?v=Fo37BlBCFfk",
"type":"video",
"provider":"www.youtube.com"
}
*/
}
});
Result Object Description
-
video :
- url : Url address of video.
- type : Video type
- width : Video width
- height : Video height
-
images [array] : If page has og:image tag return 1 else 3 images.
- src : Image url
- width : Image Width
- height : Image height
-
title : Title of page
-
description : Description of page
-
sitename : Site name
-
url : Your url
-
type :Embed type
-
provider : Provider
License
MIT