Spaces:
Paused
Paused
File size: 1,612 Bytes
f56d9f4 8d83069 f56d9f4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
const axios = require('axios');
const yts = require('yt-search');
const config = require('../config');
const { cmd, commands } = require('../command');
const { fetchJson } = require('../lib/functions');
cmd({
pattern: 'videopro',
desc: 'Search and download YouTube videos',
category: 'media',
filename: __filename
}, async (conn, mek, m, {
from,
quoted,
body,
isCmd,
command,
args,
q,
isGroup,
sender,
senderNumber,
botNumber2,
botNumber,
pushname,
isMe,
isOwner,
groupMetadata,
groupName,
participants,
groupAdmins,
isBotAdmins,
isAdmins,
reply
}) => {
try {
if (!q) return reply(`*Example*: .videopro Faded by Alan Walker`);
const searchResults = await yts(q);
const video = searchResults.all[0];
if (!video) return reply(`*No video found for ${q}*`);
const apiUrl = `https://api.davidcyriltech.my.id/download/ytmp4`;
const apiResponse = await axios.get(apiUrl, { params: { url: video.url } });
if (apiResponse.data.success) {
const { title, download_url } = apiResponse.data.result;
await reply(`*Video found!* \n\n*Title:* ${title}\n*Size:* ${apiResponse.data.result.filesize}\n*Duration:* ${video.timestamp}\n\n*Downloading...*`);
await conn.sendMessage(m.chat, { video: { url: download_url }, mimetype: 'video/mp4', caption: `📹 *${title}*` }, { quoted: m });
} else {
reply(`*Error downloading video! Please try again later.*`);
}
} catch (error) {
console.error('Error during video command:', error);
reply(`*An error occurred while processing your request.*`);
}
});
|