Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@onepunya/yt-converter-js
Advanced tools
# @onepunya/yt-converter-js
A simple Node.js class to interact with YouTube video search and conversion services.
## Installation
To use this package, you need to have Node.js installed. You can install this package via npm:
```bash
npm install @onepunya/yt-converter-js
import Youtube from '@onepunya/yt-converter-js';
or
const Youtube = require('@onepunya/yt-converter-js');
const youtube = new Youtube();
Use the search
method to search for videos based on a query.
const query = 'Kokoronashi';
youtube.search(query)
.then(result => {
console.log(result);
})
.catch(error => {
console.error('Error:', error);
});
Parameters:
query
(string): The search query string.Returns: A promise that resolves to an object with the following structure:
{
"status": "ok",
"mess": "",
"p": "search",
"items": [
{
"id": "video_id",
"title": "video_title",
"url": "https://www.youtube.com/watch?v=video_id"
}
]
}
Use the ytdlnew
method to convert a YouTube video to MP3 or MP4.
const videoUrl = 'https://www.youtube.com/watch?v=video_id';
youtube.download(videoUrl)
.then(result => {
console.log(result);
})
.catch(error => {
console.error('Error:', error);
});
Parameters:
videoUrl
(string): The URL of the YouTube video.Returns: A promise that resolves to an object with the following structure:
{
"title": "video_title",
"mp4DownloadLink": "link_to_mp4_file",
"mp3DownloadLink": "link_to_mp3_file"
}
Both methods return promises that will be rejected if an error occurs. Handle errors using .catch
in your promise chain.
This project is licensed under the MIT License
FAQs
```markdown # @onepunya/yt-converter-js
We found that @onepunya/yt-converter-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.