Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yt-converter

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yt-converter - npm Package Compare versions

Comparing version 1.3.5 to 2.0.0

dist/src/index.d.ts

41

.eslintrc.json
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true

@@ -10,25 +9,31 @@ },

],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 13
"ecmaVersion": 13,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"linebreak-style": [
"linebreak-style":["error","unix"],
"import/extensions": [
"error",
"unix"
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"quotes": [
"error",
"double"
],
"no-console":"off",
"semi": "off",
"eol-last": "off",
"no-multiple-empty-lines":"off",
"indent":["error",4],
"max-len":"off",
"comma-dangle":"off",
"no-trailing-spaces":"off",
"no-async-promise-executor":"off",
"default-param-last":"off"
"no-unused-vars":"warn"
},
"settings": {
"import/resolver":{
"node":{
"extensions":[".js",".ts"]
}
}
}
}
{
"name": "yt-converter",
"version": "1.3.5",
"version": "2.0.0",
"description": "A youtube video converter for mp3 and mp4 using node-ytdl and ffmpeg",
"main": "./src/index.js",
"main": "dist/src/index.js",
"scripts": {
"build": "jsdoc -r src -t node_modules/tsd-jsdoc/dist -d lib",
"prepublishOnly": "jsdoc -r src -t node_modules/tsd-jsdoc/dist -d lib"
"build": "tsc",
"prepublish": "tsc"
},

@@ -22,12 +22,14 @@ "keywords": [

"ffmpeg-static": "^4.4.0",
"tsd-jsdoc": "^2.5.0",
"ytdl-core": "^4.11.3"
},
"types": "lib/index.d.ts",
"types": "dist/types.d.ts",
"devDependencies": {
"eslint": "^8.5.0",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.3",
"typescript": "^5.0.4",
"yt-converter": "^1.3.0"
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},

@@ -34,0 +36,0 @@ "repository": {

# Node YoutubeDL - Easy to use downloader for YouTube videos
> [!IMPORTANT]
> Version 2.0 Released. New way to use it.
## Installation

@@ -9,44 +12,55 @@ ```bash

## Usage
### Get Info from a video
```js
const yt = require("yt-converter");
yt.getInfo("https://www.youtube.com/watch?v=dQw4w9WgXcQ").then(info => {
console.log(info);
});
There's two ways to use this library, convert audio or video. For this the package exports two functions named Audio, and Video, each one is for convert audio and video respectively.
### Converting Youtube Video to MP3 file
```ts
import { Video, Audio } from '../dist/src/index';
const link = 'https://www.youtube.com/watch?v=QI5idh3Uwh4&list=RDQI5idh3Uwh4&start_radio=1';
async function test(url:string) {
const data = await Audio({
url,
onDownloading: (d) => console.log(d),
});
console.log(data.message);
}
test(link);
```
Info represents the video information:
- **title**
- **author**
- **thumbnails**
- **formats**
- Contains the available formats for the video in an array
- The object has the property itag which can be used to convert the video
- **formatsAudio**
- **formatsVideo**
### Converting Youtube Video to MP4 file
### Download a video format mp4
```js
const yt = require("yt-converter");
yt.convertVideo({
url: "https://www.youtube.com/watch?v=JzbGrvkqV5w",
itag: 136,
directoryDownload: __dirname,
title: "Your title here"
}, onData, onClose)
```ts
import { Video, Audio } from '../dist/src/index';
const link = 'https://www.youtube.com/watch?v=QI5idh3Uwh4&list=RDQI5idh3Uwh4&start_radio=1';
async function test(url:string) {
const data = await Video({
url,
onDownloading: (d) => console.log(d),
});
console.log(data.message);
}
test(link);
```
### Function params
### Download a video format mp3
```js
const yt = require("yt-converter");
yt.convertAudio({
url: "https://www.youtube.com/watch?v=JzbGrvkqV5w",
itag: 140,
directoryDownload: __dirname,
title: "Your title here"
},onData,onClose)
```
- **itag**: [itag]("https://en.wikipedia.org/wiki/YouTube#Quality_and_formats") represent an number of video format
- **path**: path to save the file
- **onData**: callback function that is executed everytime while the file is converted
- **onClose**: callback function when the conversion is finished
Both fuctions need an options object.
* *url*: Expect to be a string representing the url link of the youtube video.
* *directory (optional)*: Path relative where you want the file converted.
* *itag*: This represents a number of a specific format. [For more information](https://en.wikipedia.org/wiki/YouTube#Quality_and_formats)
* *onDownloading (optional)* : Function will be executed while the file is downloading.
Once the functions Video and Audio are executed, returns a promise wich resolve a data object.
* *message*
* *error*
* *videoInfo*
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