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