Skip to content

pazznetwork/oembed-parser

 
 

Repository files navigation

oembed-parser

NPM Build Status Coverage Status

Installation

npm i oembed-parser

Usage

import {
  extract,
} from 'oembed-parser';

const url = 'https://www.youtube.com/watch?v=8jPQjjsBbIc';

// Promise style
extract(url).then((data) => {
  console.log(data);
}).catch((err) => {
  console.log(err);
});


// async/await style
const getArticle = async (link) => {
  try {
    let data = await extract(link);
    return data;
  } catch (err) {
    return err;
  }
}

console.log(getArticle(url));

APIs

.extract(String URL)

Return a Promise object.

.hasProvider(String URL)

Return boolean. True if the URL matches with any provider in the list.

.setProviderList(Array of provider definitions)

Sets the list of providers to use, overriding the defaults.

This can be useful for whitelisting only certain providers, or for adding custom providers.

For the expected format, see the default list.

Provider list

List of resource providers is a clone of oembed.com and available here.

Test

git clone https://github.com/ndaidong/oembed-parser.git
cd oembed-parser
npm install
npm test

License

The MIT License (MIT)

About

Extract oEmbed data from given webpage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%