Socket
Socket
Sign inDemoInstall

kyle-yt

Package Overview
Dependencies
4
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    kyle-yt

A Node.js package for YouTube API videos.


Version published
Weekly downloads
72
decreased by-81.1%
Maintainers
1
Install size
1.62 MB
Created
Weekly downloads
 

Readme

Source

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);
});

Keywords

FAQs

Last updated on 21 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc