JSPM

denethdev-ytmp3

1.0.3
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1334
    • Score
      100M100P100Q123659F
    • License ISC

    A simple Node.js package to download audio and video from the internet

    Package Exports

    • denethdev-ytmp3
    • denethdev-ytmp3/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (denethdev-ytmp3) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    YouTube MP3 Downloader

    YouTube MP3 Downloader Thumbnail

    📥 What is YouTube MP3 Downloader NPM?

    YouTube MP3 Downloader is an NPM package designed to allow users to easily download YouTube videos and convert them into high-quality MP3 files. With this tool, you can effortlessly grab MP3 audio from YouTube videos using a simple CLI or integrate it into WhatsApp and Telegram bots for automation.

    🔧 Easy Integration: Use it with bots (WhatsApp, Telegram)
    Fast Processing: Download MP3s at blazing speeds without losing quality
    🖥️ Cross-Platform: Available for macOS, Windows, and Linux.


    🛠 Features

    • ✅ Fast MP3 Downloading: Convert YouTube videos to MP3 in seconds.
    • 🤖 Bot Integration: Easily connect to WhatsApp and Telegram bots to automate MP3 downloads.
    • ⚡ Efficient and Fast: Optimized for quick processing without quality loss.
    • 🎧 Multiple Bitrates: Save in various bitrates to fit your needs 320kbps.
    • 🖥️ Cross-Platform Support: Works on all major operating systems (Windows, macOS, Linux).

    🖼️ Preview

    Check out how the YouTube MP3 Downloader looks in action:

    Preview Image 1

    🧑‍💻 Owner


    🤖 Example WhatsApp Bot Plugin

    const { cmd, commands } = require('../command');
    const yts = require('yt-search');
    const ddownr = require('denethdev-ytmp3'); // Importing the denethdev-ytmp3 package for downloading
    
    cmd({
      pattern: "song",
      desc: "Download songs.",
      category: "download",
      react: '🎧',
      filename: __filename
    }, async (messageHandler, context, quotedMessage, { from, reply, q }) => {
      try {
        if (!q) return reply("*Please Provide A Song Name or Url 🙄*");
        
        // Search for the song using yt-search
        const searchResults = await yts(q);
        if (!searchResults || searchResults.videos.length === 0) {
          return reply("*No Song Found Matching Your Query 🧐*");
        }
    
        const songData = searchResults.videos[0];
        const songUrl = songData.url;
    
        // Using denethdev-ytmp3 to fetch the download link
        const result = await ddownr.download(songUrl, 'mp3'); // Download in mp3 format
        const downloadLink = result.downloadUrl; // Get the download URL
    
        let songDetailsMessage = `*YOUTUBE AUDIO DL*\n\n`;
        songDetailsMessage += `*⚜ Title:* ${songData.title}\n`;
        songDetailsMessage += `*👀 Views:* ${songData.views}\n`;
        songDetailsMessage += `*⏰ Duration:* ${songData.timestamp}\n`;
        songDetailsMessage += `*📆 Uploaded:* ${songData.ago}\n`;
        songDetailsMessage += `*📽 Channel:* ${songData.author.name}\n`;
        songDetailsMessage += `*🖇 URL:* ${songData.url}\n\n`;
        songDetailsMessage += `*Choose Your Download Format:*\n\n`;
        songDetailsMessage += `1 || Audio File 🎶\n`;
        songDetailsMessage += `2 || Document File 📂\n\n`;
        songDetailsMessage += `> ᴅᴇɴᴇᴛʜ-ᴍᴅ ʙʏ ᴋɪɴɢ X ᴅᴇɴᴇᴛʜᴅᴇᴠ®`;
    
        // Send the video thumbnail with song details
        const sentMessage = await messageHandler.sendMessage(from, {
          image: { url: songData.thumbnail },
          caption: songDetailsMessage,
        }, { quoted: quotedMessage });
    
        // Listen for the user's reply to select the download format
        messageHandler.ev.on("messages.upsert", async (update) => {
          const message = update.messages[0];
          if (!message.message || !message.message.extendedTextMessage) return;
    
          const userReply = message.message.extendedTextMessage.text.trim();
    
          // Handle the download format choice
          if (message.message.extendedTextMessage.contextInfo.stanzaId === sentMessage.key.id) {
            switch (userReply) {
              case '1': // Audio File
                await messageHandler.sendMessage(from, {
                  audio: { url: downloadLink },
                  mimetype: "audio/mpeg"
                }, { quoted: quotedMessage });
                break;
              case '2': // Document File
                await messageHandler.sendMessage(from, {
                  document: { url: downloadLink },
                  mimetype: 'audio/mpeg',
                  fileName: `${songData.title}.mp3`,
                  caption: `${songData.title}\n\n> ᴅᴇɴᴇᴛʜ-ᴍᴅ ʙʏ ᴋɪɴɢ X ᴅᴇɴᴇᴛʜᴅᴇᴠ®`
                }, { quoted: quotedMessage });
                break;
              default:
                reply("*Invalid Option. Please Select A Valid Option 🙄*");
                break;
            }
          }
        });
      } catch (error) {
        console.error(error);
        reply("*An Error Occurred While Processing Your Request 😔*");
      }
    });
    CREATED BY DENETHDEVᵀᴹ