universal-video-provider
Install
You can install it with yarn: yarn --pure-lockfile
Description
It's a video provider, which expose some basics data extracted from famous video platforms.
This lib could be used natively on server side (node) and on client side, with a client package manager as npm, webpack, ...
Basic usage :
npm install --save universal-video-provider
or
yarn add universal-video-provider
const videoProvider = ; const provider = videoProvider;// provider is an object which contains data extraction methods provider; provider; ... provider;// video is an object which contains all the extracted data
Requirements
Run with npm and jspm. Not tested with others package managers.
Support video platforms
youtube, dailymotion, ina, digiteka
For youtube
, you have to extend the current provider with an apiKey :
videoProvider;
For digiteka
, you have to extend the current provider with credentials :
videoProvider;
Digiteka provider has a search
method to require in utlimedia catalog.
Params :
- pattern [required]
- pageToken (youtube only)
- order (youtube only)
Youtube provider has a search
method to search within youtube library. It returns an Object with 2 keys, one for the token for the next request, the second holds a videos collection matching the criteria:
// "converge" is your searchconst searcher = videoProvider // data is an object which contains all the extracted data nextPageToken: 'CAUQAA' videos: title: 'Converge - "A Single Tear"' description: 'Listen to the full album: http://bit.ly/2ypxqC7\n"A Single Tear" by Converge from the album The Dusk In Us' thumbnailUrl: 'https://i.ytimg.com/vi/DKqOp2YHfhI/maxresdefault.jpg' playerUrl: '//www.youtube.com/watch?v=DKqOp2YHfhI' duration: '04:06' pusblishedDate: '2017-09-25T19:05:29.000Z' metadata: embedCode: '//www.youtube.com/embed/DKqOp2YHfhI' provider: 'youtube' providerVideoId: 'DKqOp2YHfhI' title: 'Converge - "Precipice / All We Love We Leave Behind"' description: '"Precipice / All We Love We Leave Behind" by Converge' thumbnailUrl: 'https://i.ytimg.com/vi/akG2cFldO6I/maxresdefault.jpg' playerUrl: '//www.youtube.com/watch?v=akG2cFldO6I' duration: '06:17' publishedDate: '2017-09-25T19:05:29.000Z' metadata: embedCode: '//www.youtube.com/embed/akG2cFldO6I' provider: 'youtube' providerVideoId: 'akG2cFldO6I'
providerVideo API
getProviderFromUrl
Get a specific provider from an url.
Return:
provider Object
const provider = videoProvider;
getVideoFromUrl
Get a video from an url.
Return: video object
provider;;// video is an object which contains all the extracted data
getVideoFromId
Get a video from a provider and a video id.
Return: video object
const youtubeProvider = videoProvider;provider;;// video is an object which contains all the extracted data
extractVideoId
Extract video id from an url, with a specific provider.
Return: String
const provider = videoProvider;const videoId = videoProvider;// 'ky6CRSBcf98'
getProviderByName
Get a specific provider by his name
Return:
provider Object
videoProvider.getProviderByName('dailymotion');
getSupportedProviders
Get a list of supported provider
Return: [String]
videoProvider.getSupportedProviders();
// ['dailymotion', 'ina', 'youtube', 'digiteka']
extendProvider
Extend a current provider with new constants or methods.
Params: provider name (String), new fields (Object)
videoProvider;
extendProvider
Extend all providers with new constants or methods.
Params: new fields (Object)
videoProvider;
provider API
getThumbnailUrl
Get the thumbnail url of the video.
Params: video id
Returns: String
provider ;
getTitle
Get the title of the video.
Params: video id
Returns: String
provider ;
getDescription
Get the description of the video.
Params: video id
Returns: String
provider ;
getDuration
Get the duration of the video.
Params: video id
Returns: String
provider ;
getPublishedDate
Get the publication date of the video.
Params: video id
Returns: date
provider ;
getPlayerUrl
Get the player url of the video.
Params: video id
Returns: String
provider ;
How to contribute ?
Since js-release
is included in the project, you can make a release with it:
See the changelog: yarn release changelog
make the release: yarn release add <patch|minor|major>
This will transpile the sources (yarn build
) before creating a new release.
You can add issue, and create pull request. https://github.com/lemonde/universal-video-provider/blob/master/.github/CONTRIBUTING.md