const axios = require("axios"), fs = require("fs"), path = require("path"); const mahmud = async () => { const base = await axios.get("https://raw.githubusercontent.com/mahmudx7/HINATA/main/baseApiUrl.json"); return base.data.mahmud; }; module.exports = { config: { name: "album", version: "1.7", author: "ajmaul", countDown: 5, role: 0, category: "media", description: { bn: "বিভিন্ন ক্যাটাগরির ভিডিও অ্যালবাম দেখুন", en: "Watch video albums from various categories", vi: "Xem album video từ các danh mục khác nhau" }, guide: { bn: '{pn} [পৃষ্ঠা] | {pn} add [ক্যাটাগরি] (ভিডিও রিপ্লাই) | {pn} list', en: '{pn} [page] | {pn} add [category] (reply to video) | {pn} list', vi: '{pn} [trang] | {pn} add [danh mục] (phản hồi video) | {pn} list' } }, langs: { bn: { noInput: "× বেবি, একটি ক্যাটাগরি দাও অথবা ভিডিওতে রিপ্লাই দাও", error: "× সমস্যা হয়েছে: %1। প্রয়োজনে Contact Aizen।\n•WhatsApp: 01836298139", invalidPage: "× ভুল পৃষ্ঠা! সর্বোচ্চ পৃষ্ঠা: %1", header: "𝐀𝐯𝐚𝐢𝐥𝐚𝐛𝐥𝐞 𝐀𝐥𝐛𝐮𝐦 𝐕𝐢𝐝𝐞𝐨", footer: "\n♻ | পৃষ্ঠা [%1/%2]<😘\nℹ | টাইপ করুন !%3 %4 - পরবর্তী পৃষ্ঠা দেখতে।" }, en: { noInput: "× Baby, please specify a category or reply to a video", error: "× API error: %1. Contact Aizen for help.\n•WhatsApp: 01836298139", invalidPage: "× Invalid page! Max page: %1", header: "𝐀𝐯𝐚𝐢𝐥𝐚𝐛𝐥𝐞 𝐀𝐥𝐛𝐮𝐦 𝐕𝐢𝐝𝐞𝐨", footer: "\n♻ | 𝐏𝐚𝐠𝐞 [%1/%2]<😘\nℹ | 𝐓𝐲𝐩𝐞 !%3 %4 - 𝐭𝐨 𝐬𝐞𝐞 𝐧𝐞𝐱𝐭 𝐩𝐚𝐠𝐞." }, vi: { noInput: "× Cưng ơi, vui lòng chỉ định danh mục hoặc phản hồi video", error: "× Lỗi: %1. Liên hệ Aizen để hỗ trợ.", invalidPage: "× Trang không hợp lệ! Trang tối đa: %1", header: "𝐀𝐯𝐚𝐢𝐥𝐚𝐛𝐥𝐞 𝐀𝐥𝐛𝐮𝐦 𝐕𝐢𝐝𝐞𝐨", footer: "\n♻ | Trang [%1/%2]<😘\nℹ | Nhập !%3 %4 - để xem trang tiếp theo." } }, onStart: async function ({ api, event, args, message, getLang }) { }, onReply: async function ({ api, event, Reply, getLang, message }) { if (event.senderID !== Reply.author) return; api.unsendMessage(Reply.messageID); const category = Reply.realCategories[parseInt(event.body) - 1]; if (!category) return; try { api.setMessageReaction("⏳", event.messageID, () => {}, true); const apiBase = await mahmud(); const response = await axios.get(`${apiBase}/api/album2/mahmud/videos/${category}?userID=${event.senderID}`); const randomVideoUrl = response.data.videos[Math.floor(Math.random() * response.data.videos.length)]; const filePath = path.join(__dirname, `cache/album_${Date.now()}.mp4`); const res = await axios({ url: randomVideoUrl, method: "GET", responseType: "stream", headers: { 'User-Agent': 'Mozilla/5.0' } }); const writer = fs.createWriteStream(filePath); res.data.pipe(writer); writer.on("finish", () => { api.setMessageReaction("🪽", event.messageID, () => {}, true); message.reply({ body: Reply.captions[category] || Reply.captions["default"], attachment: fs.createReadStream(filePath) }, () => { if (fs.existsSync(filePath)) fs.unlinkSync(filePath); }); }); writer.on("error", (err) => message.reply(getLang("error", err.message))); } catch (err) { api.setMessageReaction("❌", event.messageID, () => {}, true); return message.reply(getLang("error", err.response?.data?.error || err.message)); } } };