this is custom pakages
To use this library you must have FFmpeg installed on your computer
npm install node-tube-dl
// import { YouTubeAudio } from "node-tube-dl" // Typescript
const { YouTubeAudio } = require("node-tube-dl")
const url = "https://youtube.com/watch?v=_QW9gBdDU1c"
const myfolder = "./bin"
new YouTubeAudio(url)
.codec("flac") // Get available audio codec from FFmpeg docs
.bitrate("1411k")
.channels(2)
.outdir(myfolder)
// .filename("my_music") // set filename (optional). by default the file name uses the title of the video
.extension(".flac")
.download()
.then(result => console.log(result))
.catch(e => console.log(e))
// import { YouTubeAudioV2 } from "node-tube-dl" // Typescript
const { YouTubeAudioV2 } = require("node-tube-dl")
const fs = require("fs")
const url = "https://youtube.com/watch?v=_QW9gBdDU1c"
// Example outputBuffer
// Audio output encoded to Ogg Vorbis (libvorbis), Audio file extension: .ogg
new YouTubeAudioV2(url)
.outputBuffer()
.download()
.then(async (result) => {
if (!fs.existsSync("./bin/")) {
await fs.promises.mkdir("./bin/")
}
await fs.promises.writeFile("./bin/audio.ogg", result.audioBuffer)
console.log(result)
})
.catch((e) => console.log(e))
// Example outputFile
// Audio output encoded to Ogg Vorbis (libvorbis), Audio file extension: .ogg
new YouTubeAudioV2(url)
.outputFile("./bin") // path to your folder
// .filename("my_music") // set filename (optional). by default the file name uses the title of the video
.download()
.then((result) => {
console.log(result)
})
.catch((e) => console.log(e))
// import { YouTubeVideo } from "node-tube-dl" // Typescript
const { YouTubeVideo } = require("node-tube-dl")
const url = "https://youtube.com/watch?v=_QW9gBdDU1c"
const myfolder = "./bin"
new YouTubeVideo(url)
.quality("720p") // Available quality: 144p, 240p, 360p, 480p, 720p, 1080p
.outdir(myfolder)
// .filename("my_video") // set filename (optional). by default the file name uses the title of the video
.download()
.then(result => console.log(result))
.catch(e => console.log(e))
// import { YouTubeSearch } from "node-tube-dl" // Typescript
const { YouTubeSearch } = require("node-tube-dl")
const query = "Axel Johansson"
// get all videos
new YouTubeSearch(query)
.getAllVideo()
.then(result => console.log(result.videos))
.catch(e => console.log(e))
// get specific video
new YouTubeSearch(query)
.getSpecificVideo()
.then(result => console.log(result))
.catch(e => console.log(e))