media-downloader-ez

2.1.3 • Public • Published

Multi_Color_Bar

media-downloader-ez

A simple npm package to download videos from various platforms, including Instagram, YouTube, TikTok, X/Twitter, and more.

Features

  • AutoCompress: Automatically compress videos with a size limit.
  • AutoCrop: Automatically crop videos to remove black bars.
  • Rotate: Rotate the video left or right.

image

Supported Platforms

  • Facebook
  • TikTok
  • Twitter (X)
  • Instagram
  • YouTube
  • Pinterest
  • Google Drive
  • CapCut
  • Likee
  • Threads

Basic Example

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
});

Example for Discord.js

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.


YouTube Download and Get Cookie

To download YouTube videos requiring authentication, follow these steps:

  1. Open youtube.com in your browser.
  2. Press CTRL + SHIFT + I (or right-click → Inspect).
  3. Open the Console tab.
  4. In the console, type:
    allow pasting
    
    and press Enter. (This allows pasting commands into the console.)
  5. Then, type:
    copy(document.cookie)
    
  6. Your cookie will now be copied to your clipboard. Paste it into your script where required.

Example with YouTube Cookie

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
});

Only Safe Links Example

if (MediaDownloader.isVideoLink(url)) {
    let attachment = await MediaDownloader(url, {
        autocrop: true, 
        limitSizeMB: "10", 
        rotation: "left" // or "right" or null
    });
}

Multi_Color_Bar

Package Sidebar

Install

npm i media-downloader-ez

Weekly Downloads

38

Version

2.1.3

License

ISC

Unpacked Size

71.2 kB

Total Files

10

Last publish

Collaborators

  • walkoud