1.0.0 • Published 2 years ago
simple-ytdl v1.0.0
Simple YT MP3/MP4 Downloader
Get an info or download link to any youtube videos in MP4/MP3 format. All responses are in JSON. This project was build using Axios, Cheerio, Request and API's.
HOW TO INSTALL?
npm i simple-ytdl
Require to export function
//CommonJS
const youtube = require('simple-ytdl');
SIMPLE USAGE
usage of video_search()
const youtube = require('simple-ytdl');
//Using then()
youtube.video_search({
q: 'Yoasobi Kaibutsu'
}).then((res)={
console.log(res)
})
//Using Await
let res = await youtube.video_search({
q: 'Kaibutsu Koyori ch.'
})
console.log(res)
usage of music_search()
const youtube = require('simple-ytdl');
//Using then()
youtube.music_search({
q: 'Yoasobi Kaibutsu'
}).then((res)={
console.log(res)
})
//Using Await
let res = await youtube.music_search({
q: 'Kaibutsu Koyori ch.'
})
console.log(res)
usage of download()
needed to be chained on music_search
or video_search
const youtube = require('simple-ytdl');
//btw "res.data.download_url" is the object result of music_search() or video_search() that contains download link
let stream = youtube.download(res.data.download_url)
console.log('[DOWNLOADER] Starting download now!');
stream.pipe(fs.createWriteStream('/desination/file.mp4'))
.on('finish',()=>{
console.log('[DOWNLOADER] Done!')
})
.on('error',(err)=>{
console.error('[ERROR]',err)
})
Sample Sucess Response
{
statusCode: '[OK] 200',
data: {
title: 'Freddie Dredd - All Alone (Official Video)',
uploader: 'Freddie Dredd',
upload_date: '4 months ago',
duration: '3:04',
viewCount: '7,976,254 views',
source: 'https://www.youtube.com/watch?v=mQOV11xi4SM',
format: 'MP4',
download_url: 'https://cdn-40.vevioz.com/download/mQOV11xi4SM/mp4/22/1664885332/f1a3c655950706263f23b2ac2a73cd805d0e043817fd8138209101d3663f761a/0'
}
}
{
statusCode: '[OK] 200',
data: {
title: 'Jake Hill - I Chose Violence',
uploader: 'TRASH 新 ドラゴン',
upload_date: '9 months ago',
duration: '2:20',
viewCount: '18,996,748 views',
source: 'https://www.youtube.com/watch?v=qXW8ll1z4VQ',
format: 'MP3',
download_url: 'https://cdn-30.vevioz.com/download/qXW8ll1z4VQ/mp3/320/1664885337/162a019c47b055284fbdcb1a8ae71b74503552204f821f87ee4c0d84162a1230/0'
}
}
All Params
Params | Is Required | Type | Explanation | Sample |
---|---|---|---|---|
q | yes in video_search() and music_search() | string | keyword/videoname/video link | "Snow Halation Drum Cover" |
download_url | yes when calling download() and can be obtain on result of video_search() and music_search() | string or object that contains url | A string url or object that contains string url. | "https://cdn-30.vevioz.com/download/qXW8ll1z4VQ/mp3/320/1664885337/162a019c47b055284fbdcb1a8ae71b74503552204f821f87ee4c0d84162a1230/0" |
1.0.0
2 years ago