yt-finder-nextgen
v1.3.5
Published
A Node.js/ts package for finding and retrieving YouTube downloader, audio, and images using various search methods.
Downloads
351
Maintainers
Readme
yt-finder-nextgen
yt-finder-nextgen
is a Node.js library for searching YouTube videos and downloading audio or video files in either MP3 or MP4 format. This library provides both CommonJS and ESM module support, along with TypeScript type declarations.
Installation
npm install yt-finder-nextgen
Usage
CommonJS
Search for Videos
const ytFinder = require('yt-finder-nextgen');
// Async/Await
(async () => {
try {
const result = await ytFinder.search("duvet bôa", 5);
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
// Class and Async/Await
class Search {
constructor(query, limit) {
this.query = query;
this.limit = limit;
}
search() {
return new Promise(async (resolve, reject) => {
try {
const result = await ytFinder.search(this.query, this.limit);
resolve(result);
} catch (error) {
reject(error);
}
});
}
}
(async () => {
const searchInstance = new Search("duvet bôa", 1);
try {
const result = await searchInstance.search();
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
Download Audio as MP3
const ytFinder = require('yt-finder-nextgen');
// Async/Await
(async () => {
try {
const result = await ytFinder.yt("https://m.youtube.com/watch?v=dlawQ1FkOsQ", "mp3");
console.log(result);
} catch (error) {
console.error(error);
}
})();
// Class and Async/Await
class Download {
constructor(url, option) {
this.url = url;
this.option = option;
}
download() {
return new Promise(async (resolve, reject) => {
try {
const result = await ytFinder.yt(this.url, this.option);
resolve(result);
} catch (error) {
reject(error);
}
});
}
}
(async () => {
const downloadInstance = new Download("https://m.youtube.com/watch?v=dlawQ1FkOsQ", "mp3");
try {
const result = await downloadInstance.download();
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
Download Video as MP4
const ytFinder = require('yt-finder-nextgen');
// Async/Await
(async () => {
try {
const result = await ytFinder.yt("https://m.youtube.com/watch?v=dlawQ1FkOsQ", "mp4");
console.log(result);
} catch (error) {
console.error(error);
}
})();
// Class and Async/Await
class Download {
constructor(url, option) {
this.url = url;
this.option = option;
}
download() {
return new Promise(async (resolve, reject) => {
try {
const result = await ytFinder.yt(this.url, this.option);
resolve(result);
} catch (error) {
reject(error);
}
});
}
}
(async () => {
const downloadInstance = new Download("https://m.youtube.com/watch?v=dlawQ1FkOsQ", "mp4");
try {
const result = await downloadInstance.download();
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
ESM
import ytFinder from 'yt-finder-nextgen';
// Async/Await
(async () => {
try {
const result = await ytFinder.search("duvet bôa", 5);
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
class Search {
constructor(query, limit) {
this.query = query;
this.limit = limit;
}
search() {
return new Promise(async (resolve, reject) => {
try {
const result = await ytFinder.search(this.query, this.limit);
resolve(result);
} catch (error) {
reject(error);
}
});
}
}
(async () => {
const searchInstance = new Search("duvet bôa", 1);
try {
const result = await searchInstance.search();
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
TypeScript
import ytFinder from 'yt-finder-nextgen';
interface VideoData {
title: string;
time: string;
thumbnail: string;
url: string;
views: string;
channelName: string;
}
// Async/Await
(async () => {
try {
const result: VideoData[] = await ytFinder.search("duvet bôa", 5);
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
class Search {
query: string;
limit: number;
constructor(query: string, limit: number) {
this.query = query;
this.limit = limit;
}
search(): Promise<VideoData[]> {
return new Promise(async (resolve, reject) => {
try {
const result = await ytFinder.search(this.query, this.limit);
resolve(result);
} catch (error) {
reject(error);
}
});
}
}
(async () => {
const searchInstance = new Search("duvet bôa", 1);
try {
const result: VideoData[] = await searchInstance.search();
console.log(result);
} catch (error) {
console.error('Error:', error);
}
})();
Result terminal/console
SEARCH
[
{
"title": "Bôa - Duvet (Official Video)",
"time": "3:32",
"thumbnail": "https://i.ytimg.com/vi/Uoox9fpmDP0/hqdefault.jpg?sqp=-oaymwE2COADEI4CSFXyq4qpAygIARUAAIhCGAFwAcABBvABAfgB1gSAAuADigIMCAAQARhyIFUoOjAP&rs=AOn4CLA7a2nuqlzuGNl-mj3Q5OXH5nrJ2Q",
"url": "https://www.youtube.com/watch?v=Uoox9fpmDP0",
"views": "21M views",
"channel": "Bôa"
},
{
"title": "Bôa - Duvet (Lyrics)",
"time": "3:24",
"thumbnail": "https://i.ytimg.com/vi/Ava0duwBsZo/hq720.jpg?sqp=-oaymwEcCOgCEMoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLD4szFKa-6EZcKmo3ncqhrisJrwoA",
"url": "https://www.youtube.com/watch?v=Ava0duwBsZo",
"views": "16M views",
"channel": "Taj Tracks"
}
]
AUDIO RESULT
{
"title": "Duvet (Sped Up Version)",
"description": "Provided to YouTube by Nettwerk\n\nDuvet (Sped Up Version) · bôa\n\nDuvet\n\n℗ Boa Recording Limited under exclusive license to Nettwerk Music Group Inc.\n\nReleased on: 2023-03-17\n\nProducer, Mixer: Neil Walsh\nMixer: Jason Barron\nEngineer: Steve Shin\nMusic Publisher: Paul Turrell Publishing Designee\nMusic Publisher: Steve Rodgers Publishing Designee\nMusic Publisher: Ben Henderson Publishing Designee\nMusic Publisher: Jasmine Rodgers Publishing Designee\nMusic Publisher: Alex Caird Publishing Designee\nMusic Publisher: Lee Sullivan Publishing Designee\n\nAuto-generated by YouTube.",
"viewCount": "3.6M views",
"channel": "Bôa",
"uploadDate": "Mar 16, 2023",
"subscribe": "209K subscribers",
"likes": "75K",
"link": "https://www.youtube.com/watch?v=dlawQ1FkOsQ",
"downloadLink": "https://choruofficial.chatbotcommunity.ltd/api/yt/Nextgen-by-Choru-Tikokers/duvet__sped_up_version_-b_a.mp3",
"format": "mp3"
}
VIDEO RESULT
{
"title": "Duvet (Sped Up Version)",
"description": "Provided to YouTube by Nettwerk\n\nDuvet (Sped Up Version) · bôa\n\nDuvet\n\n℗ Boa Recording Limited under exclusive license to Nettwerk Music Group Inc.\n\nReleased on: 2023-03-17\n\nProducer, Mixer: Neil Walsh\nMixer: Jason Barron\nEngineer: Steve Shin\nMusic Publisher: Paul Turrell Publishing Designee\nMusic Publisher: Steve Rodgers Publishing Designee\nMusic Publisher: Ben Henderson Publishing Designee\nMusic Publisher: Jasmine Rodgers Publishing Designee\nMusic Publisher: Alex Caird Publishing Designee\nMusic Publisher: Lee Sullivan Publishing Designee\n\nAuto-generated by YouTube.",
"viewCount": "3.6M views",
"channel": "Bôa",
"uploadDate": "Mar 16, 2023",
"subscribe": "209K subscribers",
"likes": "75K",
"link": "https://www.youtube.com/watch?v=dlawQ1FkOsQ",
"downloadLink": "https://choruofficial.chatbotcommunity.ltd/api/yt/Nextgen-by-Choru-Tikokers/duvet__sped_up_version_-b_a.mp4",
"format": "mp4"
}
License
This project is licensed under the MIT License.