A simple Node.js package to search for YouTube videos and get download URLs for MP4 and MP3 formats.
npm install downloader-by-abro
require('dotenv').config();
const YouTubeHelper = require('downloader-by-abro');
const ytHelper = new YouTubeHelper(process.env.YOUTUBE_API_KEY);
// Search for videos
ytHelper.searchVideos('Node.js tutorial', 5)
.then(videos => console.log(videos))
.catch(err => console.error(err));
// Get download URLs
ytHelper.getDownloadUrls('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
.then(urls => console.log(urls))
.catch(err => console.error(err));Creates a new instance of the YouTube helper.
apiKey: Your YouTube Data API key.
Searches for YouTube videos.
query: The search query.maxResults: Maximum number of results to return (default: 10).
Returns a Promise that resolves to an array of video objects.
Gets download URLs for a YouTube video.
videoUrl: The YouTube video URL.
Returns a Promise that resolves to an object containing MP4 and MP3 download URLs.
- Go to the Google Developers Console.
- Create a new project or select an existing one.
- Enable the YouTube Data API v3 for your project.
- Create credentials (API key) for the YouTube Data API v3.
- Store your API key securely (e.g., in a .env file) and never commit it to version control.
MIT