1.2.3 • Published 4 years ago

yt-video v1.2.3

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

yt-video

npm version downloads install size license dependencies

  A simple library for getting a video search from YouTube! Here's how it works:

Installation

Run the following command on the console:

> npm i yt-video --save

 

Usage

First, you need to get a YouTube API key on this page

 

Options

You can pass options to the search method, such as to change result ordering, video duration, etc. They are all listed on this page

 

Code examples

 

JavaScript

const ytVideo = require('yt-video');

// Create options
let options = {
  order: 'relevance',
  safeSearch: 'moderate',
  videoLicense: 'creativeCommon',
};

// Search for video "cute cats" with your API key
ytVideo('cute cats', process.env.API_KEY, options)
  .then((result) => {
    if (!result) {
      console.log('No video was found');
    } else {
      console.log('Video found!');
      console.log(`Video title: ${result.title}`);
    }
  })
  .catch((err) => {
    console.error(err);
  });

TypeScript

import ytVideo, { SearchOptions } from './lib/index';

// Create options
let options: SearchOptions = {
  order: 'relevance',
  safeSearch: 'moderate',
  videoLicense: 'creativeCommon',
};

// Search for video "cute cats" with your API key
search('cute cats', process.env.API_KEY, options)
  .then((result) => {
    if (!result) {
      console.log('No video was found');
    } else {
      console.log('Video found!');
      console.error(`Video title: ${result.title}`);
    }
  })
  .catch((err) => {
    console.error(err);
  });

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago