4.0.8 • Published 7 years ago

embedify v4.0.8

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

Embedify

Simple and robust oEmbed library. Fetches oEmbed information for Soundcloud, Spotify, Vimeo and Youtube links. The library is highly modular and new providers can be added easily (contributions welcome).

Installing

npm install embedify

Usage

const embedify = require('embedify');

const options = { parse: true };
const oEmbed = embedify.create(options);

const urls = [
  'https://www.youtube.com/embed/iOf7CsxmFCs',
  'https://play.spotify.com/track/4th1RQAelzqgY7wL53UGQt',
];

oEmbed.get(urls)
  .then(res => console.log(res));

Result

[{ 
  type: 'video',
  version: '1.0',
  title: '☼ Min sommer road trip | Del 1 ☼',
  html: '<iframe width="480" height="270" src="https://www.youtube.com/embed/iOf7CsxmFCs?feature=oembed" frameborder="0" allowfullscreen></iframe>',
  author: { 
    name: 'Amanda MIDK',
    url: 'https://www.youtube.com/user/AmandaS4G'
  },
  provider: { 
    name: 'YouTube', 
    url: 'https://www.youtube.com/' 
  },
  image: { 
    url: 'https://i.ytimg.com/vi/iOf7CsxmFCs/hqdefault.jpg',
    width: 480,
    height: 360 
  },
  width: 480,
  height: 270
},
{  
  type: 'rich',
  version: '1.0',
  title: 'Avicii - The Days',
  html: '<iframe src="https://embed.spotify.com/?uri=spotify:track:4th1RQAelzqgY7wL53UGQt" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>',
  author: {},
  provider: { 
    name: 'Spotify', 
    url: 'https://www.spotify.com' 
  },
  image: { 
    url: 'https://d3rt1990lpmkn.cloudfront.net/cover/f8717f432506ab213c4de0c66d6ac24cd07ecf72',
    width: 300,
    height: 300 
  },
  width: 300,
  height: 380
}]

API

embedify.create(options)

Creates new Embedify instance.

options

parse

Type: boolean Default: true

By default, the provider's response will be parsed and the following schema is ensured:

[{ 
  type: string,
  version: string,
  title: string,
  html: string,
  author: {
    name: string,
    url: string,
  },
  provider: {
    name: string,
    url: string,
  },
  image: {
    url: string,
    width: number,
    height: number,
  },
  width: number,
  height: number,
}]

If parse is set to false the raw response will be returned instead, like for example:

[{
  provider_url: 'https://www.spotify.com',
  version: '1.0',
  thumbnail_width: 300,
  height: 380,
  thumbnail_height: 300,
  title: ' - ',
  width: 300,
  thumbnail_url: 'https://d3rt1990lpmkn.cloudfront.net/cover/',
  provider_name: 'Spotify',
  type: 'rich',
  html: '<iframe src="https://embed.spotify.com/?uri=spotify:track:sdfgerh" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>'
}]
failSoft

Type: boolean Default: false

By default, 404 responses from provider APIs (when for example a video has been removed from Youtube etc.) will make Embedify reject the Promise with a ProviderRequestError. In cases where an empty result is preferred, failSoft can be set to true and Embedify will resolve normally with no/empty result for that particular URL.

concurrency

Type: number Default: 10

Sets the maximum number of concurrent HTTP requests to provider APIs.

oEmbed.get(urls)

Returns a Promise and resolves to oEmbed information for all URLs that matched a provider.

urls

Type: string or array<string>

URL or list of URLs to get oEmbed information for.

4.0.8

7 years ago

4.0.7

7 years ago

4.0.6

8 years ago

4.0.5

8 years ago

4.0.4

8 years ago

4.0.3

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.0

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

0.10.34

8 years ago

0.10.33

8 years ago

0.10.32

9 years ago

0.10.31

9 years ago

0.10.30

9 years ago

0.10.29

9 years ago

0.10.28

9 years ago

0.10.27

9 years ago

0.10.26

9 years ago

0.10.25

9 years ago

0.10.24

9 years ago

0.10.23

9 years ago

0.10.22

9 years ago

0.10.20

9 years ago

0.10.19

9 years ago

0.10.18

9 years ago

0.10.17

9 years ago

0.10.16

9 years ago

0.10.15

9 years ago

0.10.14

9 years ago

0.10.13

9 years ago

0.10.12

9 years ago

0.10.11

9 years ago

0.10.10

9 years ago

0.10.9

9 years ago

0.10.7

9 years ago

0.10.6

9 years ago

0.10.4

9 years ago

0.10.2

9 years ago

0.10.1

9 years ago