MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / handler

Function handler

plugins/getty.js:8–38  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

6 description: 'Download video or image from Getty Images',
7 usage: '.getty <Getty URL>',
8 async handler(sock, message, args, context) {
9 const chatId = context.chatId || message.key.remoteJid;
10 const url = args?.[0];
11 if (!url) {
12 return await sock.sendMessage(chatId, { text: 'Please provide a Getty URL.\nExample: .getty https://www.gettyimages.com/detail/video/482277170' }, { quoted: message });
13 }
14 try {
15 const apiUrl = `https://discardapi.dpdns.org/api/dl/getty?apikey=guru&url=${encodeURIComponent(url)}`;
16 const { data } = await axios.get(apiUrl, { timeout: 10000 });
17 if (!data?.status || !data.result?.length) {
18 return await sock.sendMessage(chatId, { text: '❌ No video found for this URL.' }, { quoted: message });
19 }
20 const videoUrl = data.result[0].video;
21 const imageUrl = data.result[0].image;
22 if (imageUrl) {
23 await sock.sendMessage(chatId, { image: { url: imageUrl }, caption: '🖼️ Getty Thumbnail' }, { quoted: message });
24 }
25 if (videoUrl) {
26 await sock.sendMessage(chatId, { video: { url: videoUrl }, caption: '🎬 Getty Video' }, { quoted: message });
27 }
28 }
29 catch (error) {
30 console.error('Getty plugin error:', error);
31 if (error.code === 'ECONNABORTED') {
32 await sock.sendMessage(chatId, { text: '❌ Request timed out. The API may be slow or unreachable.' }, { quoted: message });
33 }
34 else {
35 await sock.sendMessage(chatId, { text: '❌ Failed to fetch Getty video.' }, { quoted: message });
36 }
37 }
38 }
39};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected