A simple class to download YouTube videos as MP3 or other formats using the notube.net
service. It automatically handles the process of fetching the video data, initializing the download, and retrieving the download link.
- Clone the repository or download the files.
- Run
npm install
to install dependencies.
npm install axios
import YoutubeDownloader from './src/youtubDownloader.js';
(async () => {
const downloader = new YoutubeDownloader();
const url = 'https://www.youtube.com/watch?v=9bZkp7q19f0';
const data = await downloader.get(url);
const downloadLink = await downloader.download(data.token);
console.log(downloadLink);
})();
This method fetches the video data and automatically calls the initialize
method.
-
Parameters:
url
(string): The YouTube video URL.format
(string, optional): The desired format of the download. Defaults to'mp3'
.
-
Returns: A promise that resolves to the data object containing video information.
This method retrieves the download link using the token.
-
Parameters:
token
(string): The token obtained from theget()
method.
-
Returns: A promise that resolves to the download URL.
This method initializes the download process using the provided video data.
-
Parameters:
url
(string): The YouTube video URL.data
(object): The data object containing video information likeformat
,name_mp4
, andtoken
.subscribed
(boolean, optional): Set whether the video is subscribed or not. Defaults tofalse
.playlist
(boolean, optional): Set whether the video is part of a playlist. Defaults tofalse
.adblock
(boolean, optional): Set whether adblock is enabled. Defaults tofalse
.
-
Returns: A promise that resolves to the response data.
MIT License