神刀安全网

Embedify – Get oEmbed information for Soundcloud, Spotify, Vimeo and Youtube links.

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).

Embedify - Get oEmbed information for Soundcloud, Spotify, Vimeo and Youtube links.

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>',     authorName: 'Amanda MIDK',     authorUrl: 'https://www.youtube.com/user/AmandaS4G',     providerName: 'YouTube',     providerUrl: 'https://www.youtube.com/',     thumbnailUrl: 'https://i.ytimg.com/vi/iOf7CsxmFCs/hqdefault.jpg',     thumbnailWidth: 480,     thumbnailHeight: 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>',     authorName: null,     authorUrl: null,     providerName: 'Spotify',     providerUrl: 'https://www.spotify.com',     thumbnailUrl: 'https://d3rt1990lpmkn.cloudfront.net/cover/f8717f432506ab213c4de0c66d6ac24cd07ecf72',     thumbnailWidth: 300,     thumbnailHeight: 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 so that all keys are camelCase and the following schema is ensured:

{    type: string,   version: string,   title: string,   html: string,   authorName: string,   authorUrl: string,   providerName: string,   providerUrl: string,   thumbnailUrl: string,   thumbnailWidth: number,   thumbnailHeight: number,   width: number,   height: number  }  

If parse is set to false the raw response will be returned instead.

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.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Embedify – Get oEmbed information for Soundcloud, Spotify, Vimeo and Youtube links.

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址