kyle-yt

3.1.3 • Public • Published

kyle-yt 🎵

A Node.js package for YouTube API videos.

Installation 🚀

Install the package using npm:

npm install kyle-yt

Usage 🛠️

const KyleYT = require('kyle-yt');

const kyleYT = new KyleYT();

// Example usage: search for a video
kyleYT.search('The Weeknd - Save Your Tears (Official Music Video)').then(result => {
    let video = result.items[0];
    console.log('Id: ' + video.id);
    console.log('Url: ' + video.url);
    console.log('Name: ' + video.name);
    console.log('Views: ' + video.views);
}).catch(error => {
    console.error('Error:', error);
});

API 📡

search(query, options)

Searches YouTube for videos based on the given query.

  • query: The search query string.
  • options: An optional object containing search options.
    • limit: The maximum number of videos to return (default is 1).

Returns a Promise that resolves to an object containing an array of video items. Each video item has a url property representing the URL of the video.

extractVideoInfo(htmlBody, limit)

Helper function to extract video information from the HTML response.

  • htmlBody: The HTML body of the response from YouTube search.
  • limit: The maximum number of videos to extract.

Returns an array of video objects containing their URLs.

Updates 🔄

Video Download Feature

const KyleYT = require('kyle-yt');

const kyleYT = new KyleYT();

const videoURL = 'https://www.youtube.com/watch?v=jNQXAC9IVRw';
const filename = 'video.mp4';

kyleYT.download(videoURL, filename)
    .then(() => {
        console.log('Video downloaded successfully! 🎉');
    })
    .catch(error => {
        console.error('An error occurred while downloading the video:', error);
    });

Example 🌟

const KyleYT = require('kyle-yt');

const kyleYT = new KyleYT();

kyleYT.search('The Weeknd - Save Your Tears (Official Music Video)').then(result => {
    let video = result.items[0];
    console.log('Id: ' + video.id);
    console.log('Url: ' + video.url);
    console.log('Name: ' + video.name);
    console.log('Views: ' + video.views);
}).catch(error => {
    console.error('Error:', error);
});

Package Sidebar

Install

npm i kyle-yt

Weekly Downloads

126

Version

3.1.3

License

ISC

Unpacked Size

447 kB

Total Files

14

Last publish

Collaborators

  • kyle.dev