A simple npm package to download videos from various platforms, including Instagram, YouTube, TikTok, X/Twitter, and more.
- AutoCompress: Automatically compress videos with a size limit.
- AutoCrop: Automatically crop videos to remove black bars.
- Rotate: Rotate the video left or right.
- TikTok
- Twitter (X)
- YouTube
- Google Drive
- CapCut
- Likee
- Threads
const MediaDownloader = require('media-downloader-ez');
let url = "https://";
MediaDownloader(url, {
autocrop: true, // Automatically crop black bars (useful for TikTok, Instagram videos)
limitSizeMB: "10", // Maximum size limit in MB
rotation: null // Rotate video: "right", "left", or null
});
const MediaDownloader = require('media-downloader-ez');
const Discord = require('discord.js-v11-stable');
const client = new Discord.Client({
disableEveryone: true
});
client.on('message', async (message) => {
try {
if (message.content.startsWith('!download') && message.content.includes('http')) {
let attachment = await MediaDownloader(message.content, {
autocrop: true,
limitSizeMB: "10"
});
message.channel.send({ content: `Downloaded by: \`${message.author.username}\``, files: [attachment] });
}
} catch (error) {
console.error('Error downloading video:', error);
message.reply('An error occurred while downloading the video.').then((m) => { m.delete(); });
}
});
client.login("your token").catch((err) => {
console.log('INCORRECT TOKEN LOGIN!');
});
Note: Keep your Discord bot token private and secure.
To download YouTube videos requiring authentication, follow these steps:
- Open youtube.com in your browser.
- Press
CTRL + SHIFT + I
(or right-click → Inspect). - Open the Console tab.
- In the console, type:
and press Enter. (This allows pasting commands into the console.)allow pasting
- Then, type:
copy(document.cookie)
- Your cookie will now be copied to your clipboard. Paste it into your script where required.
const MediaDownloader = require('media-downloader-ez');
let url = "https://";
let cookie = "your_cookie_here";
MediaDownloader(url, {
YTBcookie: cookie, // YouTube cookie
YTBmaxduration: 80, // Maximum duration in seconds
autocrop: true, // Automatically crop black bars
limitSizeMB: "10", // Maximum size limit in MB
rotation: null // Rotate video: "right", "left", or null
});
if (MediaDownloader.isVideoLink(url)) {
let attachment = await MediaDownloader(url, {
autocrop: true,
limitSizeMB: "10",
rotation: "left" // or "right" or null
});
}