const axios = require("axios"); // Helper function to convert text to mathematical bold characters function toBold(text) { const normalChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; const boldChars = 'š—®š—Æš—°š—±š—²š—³š—“š—µš—¶š—·š—øš—¹š—ŗš—»š—¼š—½š—¾š—æš˜€š˜š˜‚š˜ƒš˜„š˜…š˜†š˜‡š—”š—•š—–š——š—˜š—™š—šš—›š—œš—š—žš—Ÿš— š—”š—¢š—£š—¤š—„š—¦š—§š—Øš—©š—Ŗš—«š—¬š—­šŸ¬šŸ­šŸ®šŸÆšŸ°šŸ±šŸ²šŸ³šŸ“šŸµ'; let result = ''; for (const char of text) { const index = normalChars.indexOf(char); result += index !== -1 ? boldChars[index] : char; } return result; } module.exports = { config: { name: "porn", version: "1.0", author: "Chitron Bhattacharjee", countDown: 5, role: 0, shortDescription: { en: "Search porn videos" }, longDescription: { en: "Search and display videos from porn.com using a search keyword" }, category: "media", guide: { en: "+porn [search term]\nExample: +porn teen" } }, onStart: async function ({ message, args, event, commandName }) { const query = args.join(" "); if (!query) return message.reply("āŒ | Please provide a search term.\nExample: +porn teen"); const apiUrl = `https://www.eporner.com/api/v2/video/search/?query=${encodeURIComponent(query)}&format=json`; try { const res = await axios.get(apiUrl); const data = res.data; if (!data?.videos?.length) { return message.reply(`āŒ | No videos found for: ${toBold(query)}`); } const topVideos = data.videos.slice(0, 10); // Prepare message with thumbnails let output = `šŸ” Results for: ${query}\n\n`; const attachments = []; for (let i = 0; i < Math.min(5, topVideos.length); i++) { const video = topVideos[i]; output += `šŸ“¼ ${i + 1}. ${video.title}\nā±ļø ${video.length_min} min | šŸ‘ ${video.rating}/5\n🌐 Url: https://www.eporner.com/video-${video.id}/${video.slug}/\n\n`; // Get thumbnail try { const thumbResponse = await axios.get(video.default_thumb.src, { responseType: 'stream' }); attachments.push(thumbResponse.data); } catch (e) { console.error(`Failed to get thumbnail for video ${i + 1}`); } } output += `\nReply with the number (1-${Math.min(5, topVideos.length)}) to get the video URL.`; await message.reply({ body: output, attachment: attachments }); // Store video data for reply handling global.GoatBot.onReply.set(event.messageID, { commandName, author: event.senderID, messageID: event.messageID, videos: topVideos }); } catch (e) { console.error(e); return message.reply("āŒ | Failed to fetch video data. Please try again later."); } }, onReply: async function ({ message, Reply, event }) { const { author, commandName, videos } = Reply; if (event.senderID !== author) return; const selectedNum = parseInt(event.body); if (isNaN(selectedNum)) { return message.reply("āŒ | Please reply with a number from the list."); } const videoIndex = selectedNum - 1; if (videoIndex < 0 || videoIndex >= Math.min(5, videos.length)) { return message.reply("āŒ | Invalid selection. Please choose a number from the list."); } const selectedVideo = videos[videoIndex]; try { // Get video embed page to extract direct video URL const embedUrl = `https://www.eporner.com/embed/${selectedVideo.id}`; const embedResponse = await axios.get(embedUrl); const embedHtml = embedResponse.data; // Extract the video source URL from the embed page const videoUrlMatch = embedHtml.match(/src="(https:\/\/[^"]+\.mp4)"/i); const videoUrl = videoUrlMatch ? videoUrlMatch[1] : null; if (!videoUrl) { throw new Error("Could not extract video URL"); } await message.reply({ body: `šŸŽ„ ${selectedVideo.title}\nā±ļø ${selectedVideo.length_min} min | šŸ‘ ${selectedVideo.rating}/5\n\nšŸ”— Direct video URL:\n${videoUrl}`, attachment: await global.utils.getStreamFromURL(selectedVideo.default_thumb.src) }); } catch (e) { console.error(e); // Fallback to page URL if direct video URL can't be obtained const fallbackUrl = `https://www.eporner.com/video-${selectedVideo.id}/${selectedVideo.slug}/`; await message.reply({ body: `šŸŽ„ ${selectedVideo.title}\nā±ļø ${selectedVideo.length_min} min | šŸ‘ ${selectedVideo.rating}/5\n\nāŒ Couldn't get direct video URL. Here's the page link:\n${fallbackUrl}`, attachment: await global.utils.getStreamFromURL(selectedVideo.default_thumb.src) }); } global.GoatBot.onReply.delete(event.messageID); } };