New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

browserify-ytdl-core

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserify-ytdl-core

YT video downloader in javascript.

  • 1.0.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

browserify-ytdl-core

browserify-ytdl-core is a TypeScript library designed to interact with the YT Data API and download video content from YT. The library is primarily intended for browser environments and features powerful functionalities such as retrieving basic information, video downloading, format selection, and more.

Installation

To use the library, you can install it via npm or yarn:

npm install browserify-ytdl-core
# or
yarn add browserify-ytdl-core

Usage

Retrieve Basic Information

import ytdl from 'browserify-ytdl-core';

const videoUrl = 'https://www.youtube.com/watch?v=your_video_id';

ytdl.getBasicInfo(videoUrl)
  .then((info) => {
    console.log('Video Title:', info.videoDetails.title);
    console.log('Author:', info.videoDetails.author);
    console.log('Views:', info.videoDetails.viewCount);
  })
  .catch((error) => {
    console.error('Error:', error.message);
  });

Download Video

import ytdl from 'browserify-ytdl-core';
import fs from 'fs';

const videoUrl = 'https://www.youtube.com/watch?v=your_video_id';
const outputFilePath = 'path/to/save/video.mp4';

const options = {
  quality: 'highest',
};

const videoStream = ytdl(videoUrl, options);
videoStream.pipe(fs.createWriteStream(outputFilePath));

videoStream.on('end', () => {
  console.log('Download complete.');
});

videoStream.on('error', (error) => {
  console.error('Download error:', error.message);
});

API

getBasicInfo(url: string, options?: ytdl.getInfoOptions): Promise<ytdl.videoInfo>

Retrieve basic information about a video from a YT URL.

ytdl(url: string, options?: ytdl.downloadOptions): Readable

Download a video from a YT URL with specified options. Returns a Readable stream.

chooseFormat(format: ytdl.videoFormat | ytdl.videoFormat[], options?: ytdl.chooseFormatOptions): ytdl.videoFormat | never

Choose a video format based on specified options.

filterFormats(formats: ytdl.videoFormat | ytdl.videoFormat[], filter?: ytdl.Filter): ytdl.videoFormat[]

Filter video formats based on the given filter.

validateID(string: string): boolean

Check the validity of a video ID.

validateURL(string: string): boolean

Check the validity of a video URL.

getURLVideoID(string: string): string | never

Get the video ID from a URL.

getVideoID(string: string): string | never

Get the video ID from a string.

version: number

The library version.

Additional Information

For more detailed information on usage and additional features, please refer to the official documentation of browserify-ytdl-core.

Contributions

If you encounter issues or have suggestions, please create an issue on GitHub. We welcome contributions from the community to enhance this library.

FAQs

Package last updated on 16 Dec 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc