const axios = require("axios"); module.exports = { config: { name: "romanticvid", aliases: ["romantic"], version: "3.1", author: "nexo_here", countDown: 5, role: 0, shortDescription: "Send romantic video", longDescription: "Send a random romantic video from saved links and Google Drive folder", category: "romantic", guide: "{p}{n}", }, // ========================================================= // SENT VIDEO HISTORY // ========================================================= sentVideos: [], // ========================================================= // GOOGLE DRIVE FOLDER // ========================================================= DRIVE_FOLDER_ID: "1oAhRcnNcnMT6xi-cNJa7Z_eH-PPeCTRo", // ========================================================= // ALL SAVED VIDEOS // ========================================================= OLD_VIDEOS: [ // ===== OLD VIDEOS ===== "https://drive.google.com/uc?export=download&id=1X-M3kUyPu4TWQL4BnjTlv0sVUeGeRidR", "https://drive.google.com/uc?export=download&id=1KXd3FVTRgZx0T3oOgpLB1DXjnpUC5abd", "https://drive.google.com/uc?export=download&id=1Q9LCLSzb6MbZ_C-wBxYmPSdICGRamWnm", "https://drive.google.com/uc?export=download&id=1SdY_8-v1iGMKNmfIVIO6WrHiq7OHy0bi", "https://drive.google.com/uc?export=download&id=1wQsDqQbDZENhhh3Q7Sd4M9cI69zy0YuM", "https://drive.google.com/uc?export=download&id=1JxFfzgcgmc2bGow8mXGjTp7qrNjrT4X-", "https://drive.google.com/uc?export=download&id=18TO8sas9HgYYjkof_FGvBWldIXgPRPLc", "https://drive.google.com/uc?export=download&id=16QHg9wilyTJ3_07IattjcgQbW9V9AKa-", "https://drive.google.com/uc?export=download&id=1MXeAp3aEcX3N7R3AqRGvNCjxkVFMiI0O", "https://drive.google.com/uc?export=download&id=1hx_72I7NDpT7IZ3niapHwe5Nv7rBaT4D", "https://drive.google.com/uc?export=download&id=1HuDDBf0Sccix6dJE7pqgK46kEyc6Irox", "https://drive.google.com/uc?export=download&id=1vXdEmA7S_TXcsI8xD0B7WRDhoYQSVFRe", "https://drive.google.com/uc?export=download&id=1AS-KTLEHbwHY7VNEQ83ORwCkNjnBJb87", // ===== PREVIOUS NEW VIDEOS ===== "https://drive.google.com/uc?export=download&id=1sJ9uH--xCzfxfTYlOfA0us-bJOrBPg0X", "https://drive.google.com/uc?export=download&id=11HDPauoW_sgAZaWj1JzAmr2UM8H0BoJB", "https://drive.google.com/uc?export=download&id=1V974CqMqSPGh8QRLMg3oQZyS-N6gOC4d", "https://drive.google.com/uc?export=download&id=11ASlq850zC1YMpq-o8fV0VuvJkQ0YKI4", "https://drive.google.com/uc?export=download&id=1ESslUAkouuoGzb9L1K0BBQGStFf4nuQn", // ===== ADDED VIDEOS ===== "https://drive.google.com/uc?export=download&id=1xvvGpHrSXzG1u76Acv3U6MHkUoqpG9JH", "https://drive.google.com/uc?export=download&id=1XDeN3fEvg4LWW02IOzrisoZV0GHjyPxe", "https://drive.google.com/uc?export=download&id=1QwgefVq6xOoxUWw5mS6DbeOqxDKr6cJ3", "https://drive.google.com/uc?export=download&id=1MmGLqdiMn8rQbI5ZBOUCht7aaShYC0RQ", "https://drive.google.com/uc?export=download&id=18wd7DU4_StHpTj_VNWhcOKApAOw5XeBI", "https://drive.google.com/uc?export=download&id=1_D4yHostIX8kYPAYGli_TH3PP2UwAAKy", ], // ========================================================= // FETCH VIDEOS FROM GOOGLE DRIVE FOLDER // ========================================================= getDriveVideos: async function () { const apiKey = process.env.GOOGLE_DRIVE_API_KEY; if (!apiKey) { console.log( "[romanticvid] GOOGLE_DRIVE_API_KEY not found." ); return []; } const videos = []; let pageToken = null; try { do { const response = await axios.get( "https://www.googleapis.com/drive/v3/files", { params: { key: apiKey, q: `'${this.DRIVE_FOLDER_ID}' in parents ` + `and trashed = false ` + `and mimeType contains 'video/'`, fields: "nextPageToken,files(id,name,mimeType,size)", pageSize: 100, ...(pageToken ? { pageToken } : {}), }, timeout: 20000, } ); const files = response.data.files || []; for (const file of files) { if (!file.id) continue; videos.push({ id: file.id, name: file.name || "Romantic Video", mimeType: file.mimeType || "video/mp4", size: file.size || null, url: `https://drive.google.com/uc?export=download&id=${file.id}`, }); } pageToken = response.data.nextPageToken || null; } while (pageToken); console.log( `[romanticvid] ${videos.length} video(s) found in Google Drive folder.` ); return videos; } catch (error) { console.error( "[romanticvid] Google Drive API error:", error.response?.data || error.message ); return []; } }, // ========================================================= // COMMAND // ========================================================= onStart: async function ({ api, event, message, }) { let loadingMessage; try { loadingMessage = await message.reply({ body: "Romantic video dicchi ektu Dara 😌❤️", }); } catch (error) { console.error( "[romanticvid] Loading message error:", error ); } try { // ===================================================== // FETCH FOLDER VIDEOS // ===================================================== const driveVideos = await this.getDriveVideos(); const folderLinks = driveVideos.map( video => video.url ); // ===================================================== // COMBINE ALL VIDEOS // ===================================================== const allVideos = [ ...this.OLD_VIDEOS, ...folderLinks, ]; // Remove duplicate links const links = [ ...new Set(allVideos), ]; if (links.length === 0) { if (loadingMessage) { try { await api.unsendMessage( loadingMessage.messageID ); } catch (e) {} } return message.reply( "💖 এখনো কোনো romantic video পাওয়া যায়নি।" ); } // ===================================================== // FIND UNUSED VIDEOS // ===================================================== let availableVideos = links.filter( video => !this.sentVideos.includes(video) ); // ===================================================== // RESET HISTORY // ===================================================== if (availableVideos.length === 0) { this.sentVideos = []; availableVideos = [...links]; } // ===================================================== // RANDOM VIDEO // ===================================================== const randomVideo = availableVideos[ Math.floor( Math.random() * availableVideos.length ) ]; // Save history this.sentVideos.push(randomVideo); // ===================================================== // HISTORY LIMIT // ===================================================== if ( this.sentVideos.length > links.length ) { this.sentVideos = this.sentVideos.slice( -links.length ); } // ===================================================== // GET VIDEO STREAM // ===================================================== const videoStream = await global.utils.getStreamFromURL( randomVideo ); // ===================================================== // SEND VIDEO // ===================================================== await message.reply({ body: "𝐓𝐨𝐦𝐫𝐚 𝐩𝐨𝐥𝐚 𝐠𝐨 𝐝𝐚𝐤𝐨🥵❤️", attachment: videoStream, }); // ===================================================== // DELETE LOADING MESSAGE // ===================================================== if (loadingMessage) { setTimeout(async () => { try { await api.unsendMessage( loadingMessage.messageID ); } catch (e) {} }, 3000); } } catch (error) { console.error( "[romanticvid] Error:", error ); // Delete loading message if (loadingMessage) { try { await api.unsendMessage( loadingMessage.messageID ); } catch (e) {} } return message.reply( "❌ ভিডিও পাঠানো যায়নি।\n\n" + "Google Drive video Public আছে কিনা check করো।" ); } }, };