diff --git "a/index.js" "b/index.js"
new file mode 100644--- /dev/null
+++ "b/index.js"
@@ -0,0 +1,5835 @@
+import fs from 'fs';
+import os from 'os';
+import qs from 'qs';
+import http from 'http';
+import express from 'express';
+import FormData from "form-data";
+import ytSearch from "yt-search";
+import path from 'path';
+ import axios from 'axios';
+
+ import translate from "@vitalets/google-translate-api";
+import crypto from 'crypto';
+import { v4 as uuidv4 } from "uuid";
+
+import QRCode from "qrcode";
+
+import { fileURLToPath } from 'url';
+import dotenv from 'dotenv';
+import { Mp3,
+ Mp4,
+ tiktokdl,
+ Lyrics,
+ ddownr,
+ svweb,
+ chatbot } from './exports/index.js';
+
+const __filename = fileURLToPath(import.meta.url),
+ __dirname = path.dirname(__filename);
+dotenv.config({ path: path.join(__dirname, '.env') });
+
+const app = express();
+app.use(express.json());
+const serverStartTime = Date.now();
+
+const port = process.env.PORT || 3000;
+app.enable('trust proxy');
+app.set('json spaces', 2);
+app.use(express.static(path.join(__dirname, 'public')));
+import cors from 'cors';
+app.use(cors());
+
+import mongoose from 'mongoose';
+
+import cheerio from 'cheerio'
+
+import bcrypt from 'bcrypt';
+
+import bodyParser from 'body-parser';
+
+
+
+// Middleware
+app.use(bodyParser.urlencoded({ extended: true }));
+app.use(express.static("public"));
+
+
+import session from 'express-session';
+
+
+
+
+
+
+
+import flash from 'express-flash' ;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// Middleware to parse JSON and form data
+
+
+
+
+
+
+
+
+const byteToKB = 1 / 1024,
+ byteToMB = 1 / Math.pow(1024, 2),
+ byteToGB = 1 / Math.pow(1024, 3);
+
+// Utility Functions
+function formatBytes(bytes) {
+ if (bytes >= Math.pow(1024, 3)) {
+ return (bytes * byteToGB).toFixed(2) + ' GB';
+ } else if (bytes >= Math.pow(1024, 2)) {
+ return (bytes * byteToMB).toFixed(2) + ' MB';
+ } else if (bytes >= 1024) {
+ return (bytes * byteToKB).toFixed(2) + ' KB';
+ } else {
+ return bytes.toFixed(2) + ' bytes';
+ }
+}
+
+function runtime(seconds) {
+ seconds = Number(seconds);
+ const d = Math.floor(seconds / (3600 * 24)),
+ h = Math.floor((seconds % (3600 * 24)) / 3600),
+ m = Math.floor((seconds % 3600) / 60),
+ s = Math.floor(seconds % 60),
+ dDisplay = d > 0 ? d + (d === 1 ? ' day, ' : ' days, ') : '',
+ hDisplay = h > 0 ? h + (h === 1 ? ' hour, ' : ' hours, ') : '',
+ mDisplay = m > 0 ? m + (m === 1 ? ' minute, ' : ' minutes, ') : '',
+ sDisplay = s > 0 ? s + (s === 1 ? ' second' : ' seconds') : '';
+ return dDisplay + hDisplay + mDisplay + sDisplay;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+app.use(express.json());
+
+
+
+
+
+
+
+
+import getLyrics from "@faouzkk/lyrics-finder";
+
+// ๐ Route to Fetch Lyrics
+app.get("/lyrics3", async (req, res) => {
+ const { song, artist } = req.query;
+
+ if (!song) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: 400,
+ success: false,
+ message: "Please provide a song name using the `song` query parameter.",
+ });
+ }
+
+ try {
+ const lyrics = await getLyrics(song, artist);
+
+ if (!lyrics) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ status: 404,
+ success: false,
+ message: "Lyrics not found for the requested song.",
+ });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ result: {
+ song: song,
+ artist: artist || "Unknown",
+ lyrics: lyrics,
+ },
+ });
+ } catch (error) {
+ console.error("Error fetching lyrics:", error.message);
+
+ res.status(500).json({
+ creator: "David Cyril",
+ status: 500,
+ success: false,
+ message: "An error occurred while fetching lyrics.",
+ });
+ }
+});
+
+
+
+
+
+
+import jsconfuser from "js-confuser";
+
+
+
+
+
+// ๐ Route to Obfuscate JavaScript Code
+app.get("/obfuscate", async (req, res) => {
+ const { code, level } = req.query;
+
+ if (!code) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: 400,
+ success: false,
+ message: "Please provide JavaScript code using the `code` query parameter.",
+ });
+ }
+
+ // Define obfuscation levels with valid settings
+ const levels = {
+ low: { target: "node", preset: "low" },
+ medium: { target: "node", preset: "medium" },
+ high: { target: "node", preset: "high" },
+ extreme: {
+ target: "node",
+ preset: "high",
+ stringCompression: true,
+ shuffle: true,
+ globalVariables: true,
+ },
+ };
+
+ // Select obfuscation level (default: medium)
+ const options = levels[level] || levels.medium;
+
+ try {
+ const obfuscatedCode = await jsconfuser.obfuscate(code, options);
+
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ result: {
+ original_code: code,
+ obfuscated_code: obfuscatedCode,
+ },
+ });
+ } catch (error) {
+ console.error("Error obfuscating code:", error.message);
+
+ res.status(500).json({
+ creator: "David Cyril",
+ status: 500,
+ success: false,
+ message: "An error occurred while obfuscating the code.",
+ });
+ }
+});
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+const formatAudio = ["mp3", "m4a", "webm", "aac", "flac", "opus", "ogg", "wav"];
+
+// YouTube MP3 Download Endpoint
+app.get("/download/ytmp3", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: CREATOR,
+ status: 400,
+ success: false,
+ message: "Please provide a valid YouTube URL",
+ });
+ }
+
+ try {
+ // Get download info using ytdlocean
+ const result = await ytdlocean(url, "mp3");
+ const videoId = extractYouTubeID(url);
+
+ // Return the EXACT old response structure
+ res.json({
+ creator: CREATOR,
+ status: 200,
+ success: true,
+ result: {
+ type: "audio",
+ quality: "128kbps",
+ title: result.title || "YouTube Audio",
+ thumbnail: result.image || `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`,
+ download_url: result.downloadUrl
+ }
+ });
+
+ } catch (error) {
+ console.error('Download error:', error.message);
+ return res.status(500).json({
+ creator: CREATOR,
+ status: 500,
+ success: false,
+ message: error.message || "Failed to process request"
+ });
+ }
+});
+
+// Your existing functions
+async function cekProgress(id) {
+ const config = {
+ method: "GET",
+ url: `https://p.oceansaver.in/ajax/progress.php?id=${id}`,
+ headers: {
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
+ }
+ };
+
+ while (true) {
+ const response = await axios.request(config);
+ if (response.data?.success && response.data.progress === 1000) {
+ return response.data.download_url;
+ }
+ await new Promise(resolve => setTimeout(resolve, 5000));
+ }
+}
+
+async function ytdlocean(url, format = "mp3") {
+ if (!formatAudio.includes(format)) {
+ throw new Error("Invalid format. Use a valid audio format.");
+ }
+
+ const config = {
+ method: "GET",
+ url: `https://p.oceansaver.in/ajax/download.php?format=${format}&url=${encodeURIComponent(url)}&api=dfcb6d76f2f6a9894gjkege8a4ab232222`,
+ headers: {
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
+ }
+ };
+
+ const response = await axios.request(config);
+ if (response.data?.success) {
+ const { id, title, info: { image } } = response.data;
+ const downloadUrl = await cekProgress(id);
+ return { id, title, image, downloadUrl };
+ } else {
+ throw new Error("Failed to fetch video details.");
+ }
+}
+
+function extractYouTubeID(url) {
+ const match = url.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?/\s]{11})/);
+ return match ? match[1] : null;
+}
+
+
+
+
+
+
+
+
+app.get("/download/ytmp333", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril Tech",
+ status: 400,
+ success: false,
+ message: "Please provide a valid YouTube video URL using the `url` query parameter.",
+ });
+ }
+
+ try {
+ // Fetch from the new downloader API
+ const response = await axios.get(`https://dl55.yt-dl.click/api/download?url=${encodeURIComponent(url)}&format=mp3`);
+
+ if (!response.data || !response.data.result || !response.data.result.download) {
+ throw new Error("Invalid response from downloader API.");
+ }
+
+ const result = response.data.result;
+
+ // Send the JSON response in the required format
+ res.json({
+ status: true,
+ result: {
+ title: result.title || "YouTube MP3",
+ type: "audio",
+ format: "mp3",
+ quality: "128",
+ duration: result.duration || "Unknown",
+ thumbnail: result.thumbnail || `https://img.youtube.com/vi/${extractYouTubeID(url)}/hqdefault.jpg`,
+ download: result.download, // Direct download link
+ },
+ });
+
+ } catch (error) {
+ console.error("Error processing YouTube MP3 request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril Tech",
+ status: 500,
+ success: false,
+ message: "Failed to download MP3. Please try again.",
+ });
+ }
+});
+
+
+
+
+
+// Direct Download Proxy
+app.get("/download/proxy", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril Tech",
+ status: 400,
+ success: false,
+ message: "Please provide a valid file URL using `url` parameter.",
+ });
+ }
+
+ try {
+ // Fetch the MP3 file from CDN
+ const response = await axios({
+ method: "GET",
+ url: url,
+ responseType: "stream",
+ });
+
+ // Set headers to force download
+ res.setHeader("Content-Disposition", `attachment; filename="audio.mp3"`);
+ res.setHeader("Content-Type", "audio/mpeg");
+
+ // Pipe the file to the response
+ response.data.pipe(res);
+ } catch (error) {
+ console.error("Download Proxy Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril Tech",
+ status: 500,
+ success: false,
+ message: "Failed to fetch the file. Please try again.",
+ });
+ }
+});
+
+
+
+
+
+
+
+// Facebook Download Endpoint
+app.get("/facebook", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({ error: "URL parameter is required" });
+ }
+
+ try {
+ // Use the fbdown function to fetch video details
+ const result = await fbdown(url);
+
+ // Restructure the response to match your desired format
+ const response = {
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ video: {
+ thumbnail: result.thumb,
+ downloads: [
+ {
+ quality: "SD",
+ downloadUrl: result.sd,
+ },
+ ...(result.hd
+ ? [
+ {
+ quality: "HD",
+ downloadUrl: result.hd,
+ },
+ ]
+ : []),
+ ],
+ },
+ };
+
+ return res.json(response);
+ } catch (error) {
+ console.error("Error fetching data:", error.message);
+ return res.status(500).json({ error: "An error occurred while processing the request" });
+ }
+});
+
+// Function to download Facebook video using cheerio
+async function fbdown(url) {
+ return new Promise(async (resolve, reject) => {
+ try {
+ let params = new URLSearchParams();
+ params.append("URLz", url);
+
+ let res = await axios.post("https://fdown.net/download.php", params, {
+ headers: {
+ Origin: "https://fdown.net",
+ Referer: "https://fdown.net/",
+ },
+ });
+
+ let html = res.data;
+ let $ = cheerio.load(html);
+
+ const thumb = $("#result > div.col-xs-6.col-xs-offset-3.no-padding.lib-item > div > div > div:nth-child(1) > img").attr("src");
+ const title = $("#result > div.col-xs-6.col-xs-offset-3.no-padding.lib-item > div > div > div:nth-child(2) > div.lib-row.lib-header").text().trim();
+ const desc = $("#result > div.col-xs-6.col-xs-offset-3.no-padding.lib-item > div > div > div:nth-child(2) > div:nth-child(2)").text().trim().split(":")[1];
+ const sd = $("#sdlink").attr("href");
+ const hd = $("#hdlink").attr("href");
+
+ if (!sd) {
+ reject(new Error("Failed to fetch video details"));
+ } else {
+ resolve({ thumb, title, desc, sd, hd });
+ }
+ } catch (error) {
+ reject(error);
+ }
+ });
+}
+
+
+
+
+app.get("/download/ytmp4", async (req, res) => {
+ const { url, format = "720" } = req.query; // Default to 720p if format isn't provided
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: 400,
+ success: false,
+ message: "Please provide a valid YouTube video URL using the `url` query parameter.",
+ });
+ }
+
+ try {
+ // Call the new API
+ const response = await axios.get(`https://ytdl.siputzx.my.id/api/convert?url=${encodeURIComponent(url)}&type=mp4`);
+
+ if (!response.data || !response.data.dl) {
+ return res.status(500).json({
+ creator: "David Cyril",
+ status: 500,
+ success: false,
+ message: "Failed to fetch download link. Please try again later.",
+ });
+ }
+
+ // Return response in the old format
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ result: {
+ type: "video",
+ quality: `${format}p`,
+ title: response.data.title,
+ thumbnail: `https://img.youtube.com/vi/${url.split("v=")[1]}/hqdefault.jpg`,
+ download_url: response.data.dl,
+ },
+ });
+ } catch (error) {
+ console.error("Error processing YouTube MP4 request:", error.message);
+
+ res.status(500).json({
+ creator: "David Cyril",
+ status: 500,
+ success: false,
+ message: "An unexpected error occurred while processing the request. Please try again later.",
+ });
+ }
+});
+
+
+
+
+
+// Function to check download progress for MP3
+async function checkAudioProgress(audioId) {
+ const config = {
+ method: "GET",
+ url: `https://p.oceansaver.in/ajax/progress.php?id=${audioId}`,
+ headers: {
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
+ },
+ };
+
+ while (true) {
+ const response = await axios.request(config);
+ if (response.data?.success && response.data.progress === 1000) {
+ return response.data.download_url;
+ }
+ await new Promise((resolve) => setTimeout(resolve, 5000)); // Retry every 5 seconds
+ }
+}
+
+// Function to fetch YouTube MP3 Download Link
+async function fetchAudioDownload(audioUrl) {
+ const config = {
+ method: "GET",
+ url: `https://p.oceansaver.in/ajax/download.php?format=mp3&url=${encodeURIComponent(audioUrl)}&api=dfcb6d76f2f6a9894gjkege8a4ab232222`,
+ headers: {
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
+ },
+ };
+
+ const response = await axios.request(config);
+ if (response.data?.success) {
+ const { id, title, info } = response.data;
+ const mp3DownloadUrl = await checkAudioProgress(id);
+ return { title, thumbnail: info.image, mp3DownloadUrl };
+ } else {
+ throw new Error("Failed to fetch MP3 download link.");
+ }
+}
+
+// Function to fetch YouTube MP4 Download Link
+async function fetchVideoDownload(videoUrl) {
+ const response = await axios.get(`https://ytdl.siputzx.my.id/api/convert?url=${encodeURIComponent(videoUrl)}&type=mp4`);
+
+ if (!response.data || !response.data.dl) {
+ throw new Error("Failed to fetch MP4 download link.");
+ }
+
+ return response.data.dl; // Return the direct video link
+}
+
+
+
+
+
+import { spawn } from "child_process";
+
+
+
+// Function to upload directly to Catbox
+async function uploadToCatbox(stream, filename) {
+ try {
+ const form = new FormData();
+ form.append("reqtype", "fileupload");
+ form.append("fileToUpload", stream, { filename });
+
+ const response = await axios.post("https://catbox.moe/user/api.php", form, {
+ headers: form.getHeaders(),
+ });
+
+ return response.data.trim(); // Returns direct URL
+ } catch (error) {
+ console.error("Catbox Upload Error:", error.message);
+ return null;
+ }
+}
+
+// Function to process media using FFmpeg (No File Storage)
+function processMedia(inputUrl, ffmpegArgs, filename) {
+ return new Promise((resolve, reject) => {
+ const ffmpeg = spawn("ffmpeg", ["-i", inputUrl, ...ffmpegArgs, "-f", "mp4", "pipe:1"]);
+
+ resolve(uploadToCatbox(ffmpeg.stdout, filename));
+ });
+}
+
+// API: Convert Video to MP3 (No Local Storage)
+app.get("/convert/mp3", async (req, res) => {
+ const { url } = req.query;
+ if (!url) return res.status(400).json({ error: "Provide a video URL." });
+
+ try {
+ const fileUrl = await processMedia(url, ["-q:a", "0", "-map", "a"], "output.mp3");
+ if (!fileUrl) throw new Error("Failed to upload to Catbox.");
+
+ res.json({ success: true, url: fileUrl });
+ } catch (error) {
+ res.status(500).json({ error: error.message });
+ }
+});
+
+// API: Reverse Video
+app.get("/convert/reverse", async (req, res) => {
+ const { url } = req.query;
+ if (!url) return res.status(400).json({ error: "Provide a video URL." });
+
+ try {
+ const fileUrl = await processMedia(url, ["-vf", "reverse", "-af", "areverse"], "reversed.mp4");
+ if (!fileUrl) throw new Error("Failed to upload to Catbox.");
+
+ res.json({ success: true, url: fileUrl });
+ } catch (error) {
+ res.status(500).json({ error: error.message });
+ }
+});
+
+
+
+
+
+
+// YouTube Song Command API
+app.get("/song", async (req, res) => {
+ const { query } = req.query;
+
+ if (!query) {
+ return res.status(400).json({
+ creator: CREATOR,
+ status: false,
+ message: "Please provide a search query.",
+ });
+ }
+
+ try {
+ // Search YouTube for the song
+ const searchResults = await ytSearch(query);
+
+ if (!searchResults.videos.length) {
+ return res.json({
+ creator: CREATOR,
+ status: false,
+ message: "No results found.",
+ });
+ }
+
+ // Get first video result
+ const songResult = searchResults.videos[0];
+ const videoId = extractYouTubeID(songResult.url);
+
+ // Fetch MP3 and MP4 download links simultaneously
+ const [mp3Data, mp4Url] = await Promise.all([
+ fetchAudioDownload(songResult.url),
+ fetchVideoDownload(songResult.url),
+ ]);
+
+ // Response JSON
+ res.json({
+ creator: CREATOR,
+ status: true,
+ result: {
+ title: songResult.title,
+ video_url: songResult.url,
+ thumbnail: songResult.thumbnail || `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`,
+ duration: songResult.duration.timestamp,
+ views: songResult.views,
+ published: songResult.ago,
+ audio: {
+ format: "MP3",
+ quality: "128kbps",
+ download_url: mp3Data.mp3DownloadUrl,
+ },
+ video: {
+ format: "MP4",
+ quality: "720p",
+ download_url: mp4Url,
+ },
+ },
+ });
+ } catch (error) {
+ console.error("Error processing YouTube song request:", error.message);
+ res.status(500).json({
+ creator: CREATOR,
+ status: false,
+ message: "Failed to process request. Please try again.",
+ });
+ }
+});
+
+
+
+
+
+
+const fdown = {
+ getToken: async () => {
+ try {
+ const response = await axios.get('https://fdown.net', {
+ headers: {
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
+ 'Accept': 'text/html,application/xhtml+xml',
+ }
+ });
+
+ const $ = cheerio.load(response.data);
+ return {
+ token_v: $('input[name="token_v"]').val(),
+ token_c: $('input[name="token_c"]').val(),
+ token_h: $('input[name="token_h"]').val()
+ };
+ } catch (error) {
+ console.error('Error fetching tokens:', error.message);
+ return null;
+ }
+ },
+
+ download: async (url) => {
+ const tokens = await fdown.getToken();
+ if (!tokens) return null;
+
+ const formData = qs.stringify({
+ 'URLz': url,
+ 'token_v': tokens.token_v,
+ 'token_c': tokens.token_c,
+ 'token_h': tokens.token_h
+ });
+
+ try {
+ const response = await axios.post('https://fdown.net/download.php', formData, {
+ headers: {
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ }
+ });
+
+ const $ = cheerio.load(response.data);
+ const video = {
+ title: $('#result .lib-header').text().trim() || "Unknown Title",
+ description: $('#result .lib-desc').first().text().replace('Description:', '').trim() || "No Description",
+ duration: $('#result .lib-desc').last().text().replace('Duration:', '').trim() || "Unknown",
+ thumbnail: $('#result .lib-img-show').attr('data-cfsrc') || $('#result .lib-img-show').attr('src') || null,
+ downloads: []
+ };
+
+ const normalQualityLink = $('#sdlink').attr('href');
+ const hdQualityLink = $('#hdlink').attr('href');
+
+ if (normalQualityLink) {
+ video.downloads.push({ quality: 'SD', downloadUrl: normalQualityLink });
+ }
+ if (hdQualityLink) {
+ video.downloads.push({ quality: 'HD', downloadUrl: hdQualityLink });
+ }
+
+ return video;
+ } catch (error) {
+ console.error('Error downloading video:', error.message);
+ return null;
+ }
+ }
+};
+
+
+const categories = [
+ "genshin", "swimsuit", "schoolswimsuit", "white", "barefoot", "touhou", "gamecg",
+ "hololive", "uncensored", "sungglasses", "glasses", "weapon", "shirtlift", "chain",
+ "fingering", "flatchest", "torncloth", "bondage", "demon", "pantypull", "headdress",
+ "headphone", "anusview", "shorts", "stokings", "topless", "beach", "bunnygirl",
+ "bunnyear", "vampire", "nobra", "bikini", "whitehair", "blonde", "pinkhair", "bed",
+ "ponytail", "nude", "dress", "underwear", "foxgirl", "uniform", "skirt", "breast",
+ "twintail", "spreadpussy", "seethrough", "breasthold", "fateseries", "spreadlegs",
+ "openshirt", "headband", "nipples", "erectnipples", "greenhair", "wolfgirl", "catgirl"
+];
+
+// Main NSFW Route
+app.get("/nsfw", async (req, res) => {
+ const { category } = req.query;
+
+ // If no category, show available categories
+ if (!category) {
+ return res.json({
+ creator: "David Cyril",
+ success: true,
+ message: "Available categories",
+ categories: categories
+ });
+ }
+
+ // Check if the category is valid
+ if (!categories.includes(category.toLowerCase())) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Invalid category. Use /nsfw to see available categories."
+ });
+ }
+
+ try {
+ // Fetch image URL from external API
+ const response = await axios.get(`https://fantox-apis.vercel.app/${category}`);
+ if (!response.data || !response.data.url) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No image found for this category."
+ });
+ }
+
+ // Redirect browser to the image URL (Displays image directly)
+ return res.redirect(response.data.url);
+
+ } catch (error) {
+ console.error("Error fetching NSFW image:", error.message);
+ return res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+app.get("/random/technews", async (req, res) => {
+ try {
+ const response = await axios.get("https://bk9.fun/details/tnews");
+ const newsData = response.data.BK9;
+
+ if (!newsData) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ status: false,
+ message: "No tech news found."
+ });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ result: {
+ title: newsData.title,
+ link: newsData.link,
+ image: newsData.img,
+ description: newsData.desc
+ }
+ });
+ } catch (error) {
+ console.error("Error fetching tech news:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "An error occurred while fetching tech news."
+ });
+ }
+});
+
+app.get("/tts", async (req, res) => {
+ const { text, voice } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ error: "Please provide the text in the `text` query parameter."
+ });
+ }
+
+ if (!voice) {
+ try {
+ // Fetch available voices from the API
+ const response = await axios.get("https://api.paxsenix.biz.id/tools/tts?text=test");
+
+ if (!response.data.ok) {
+ throw new Error("Failed to fetch available voices");
+ }
+
+ return res.status(400).json({
+ creator: "David Cyril",
+ error: "Please provide the voice in the `voice` query parameter.",
+ availableVoices: response.data.available_voices
+ });
+ } catch (error) {
+ console.error("Error fetching available voices:", error.message);
+ return res.status(500).json({
+ creator: "David Cyril",
+ error: "An error occurred while fetching available voices."
+ });
+ }
+ }
+
+ try {
+ const apiUrl = `https://api.paxsenix.biz.id/tools/tts?text=${encodeURIComponent(
+ text
+ )}&voice=${encodeURIComponent(voice)}`;
+
+ const response = await axios.get(apiUrl);
+
+ if (response.data.ok) {
+ res.status(200).json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ audioUrl: response.data.directUrl
+ });
+ } else {
+ res.status(400).json({
+ creator: "David Cyril",
+ error: "The voice you selected is not available. Please choose a valid voice.",
+ availableVoices: response.data.available_voices
+ });
+ }
+ } catch (error) {
+ console.error("Error generating TTS:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+app.get("/tools/stackoverflow_details", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "Please provide a valid Stack Overflow URL."
+ });
+ }
+
+ try {
+ const response = await axios.get(url);
+ const $ = cheerio.load(response.data);
+
+ // Extract data from Stack Overflow page
+ const title = $("h1.fs-headline1").text().trim();
+ const image = "https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a";
+ const content = $(".js-post-body").first().text().trim();
+ const time = $("time").first().text().trim();
+ const author = $(".user-details a").first().text().trim();
+ const questions = $(".post-tag").map((i, el) => $(el).text()).get();
+
+ if (!title || !content) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ status: false,
+ message: "Failed to fetch Stack Overflow details."
+ });
+ }
+
+ // Construct response
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ BK9: {
+ title: title,
+ link: url,
+ image: image,
+ content: content,
+ time: time || "Unknown",
+ author: author || "Unknown",
+ questions: questions || []
+ }
+ });
+
+ } catch (error) {
+ console.error("Error fetching Stack Overflow details:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "An error occurred while processing your request."
+ });
+ }
+});
+
+app.get('/facebook2', async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "Please provide a valid Facebook video URL."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.agatz.xyz/api/facebook`, {
+ params: { url }
+ });
+
+ const data = response.data.data;
+
+ if (!data || (!data.sd && !data.hd)) {
+ return res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "Failed to fetch video details. Please try again later."
+ });
+ }
+
+ // Maintain old API response structure
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ video: {
+ title: data.title || "No title available",
+ thumbnail: data.thumbnail || null,
+ downloads: [
+ data.sd ? { quality: "SD", downloadUrl: data.sd } : null,
+ data.hd ? { quality: "HD", downloadUrl: data.hd } : null
+ ].filter(Boolean)
+ }
+ });
+
+ } catch (error) {
+ console.error('Error fetching Facebook video:', error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+app.get("/spotifydl", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ error: "Please provide the Spotify URL in the `url` query parameter."
+ });
+ }
+
+ try {
+ const apiUrl = `https://api.agatz.xyz/api/spotifydl?url=${encodeURIComponent(url)}`;
+ const response = await axios.get(apiUrl);
+
+ if (response.data.status === 200) {
+ const spotifyData = JSON.parse(response.data.data);
+
+ res.status(200).json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ channel: spotifyData.nama_channel,
+ title: spotifyData.judul,
+ duration: `${spotifyData.durasi} seconds`,
+ thumbnail: spotifyData.gambar_kecil[0].url,
+ DownloadLink: spotifyData.url_audio_v1,
+ });
+ } else {
+ res.status(404).json({
+ creator: "David Cyril",
+ error: "Spotify data could not be retrieved."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching Spotify data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+const availableModels = [
+ "miku",
+ "nahida",
+ "nami",
+ "ana",
+ "optimus_prime",
+ "goku",
+ "taylor_swift",
+ "elon_musk",
+ "mickey_mouse",
+ "kendrick_lamar",
+ "angela_adkinsh",
+ "eminem"
+];
+
+app.get("/voiceai", async (req, res) => {
+ const { text, model } = req.query;
+
+ // Validate inputs
+ if (!text) {
+ return res.status(400).json({ error: "The 'text' parameter is required." });
+ }
+
+ if (!model || !availableModels.includes(model)) {
+ return res.status(400).json({
+ error: `Invalid 'model' parameter. Available models: ${availableModels.join(", ")}`
+ });
+ }
+
+ try {
+ // Call the API
+ const response = await axios.get(
+ `https://api.agatz.xyz/api/voiceover?text=${encodeURIComponent(text)}&model=${model}`
+ );
+ const data = response.data;
+
+ if (data.error) {
+ return res.status(500).json({ error: data.error });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ model: data.data.model,
+ voice_name: data.data.voice_name,
+ audio_url: data.data.oss_url
+ });
+ } catch (error) {
+ console.error("Error fetching voiceover:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+import shortid from 'shortid';
+
+
+
+app.use(cors());
+
+
+
+
+
+app.get("/pickupline", async (req, res) => {
+ try {
+ // Call the Popcat API for pickup lines
+ const response = await axios.get("https://api.popcat.xyz/pickuplines");
+ const data = response.data;
+
+ // Send the pickup line and contributor as a response
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ pickupline: data.pickupline
+ });
+ } catch (error) {
+ console.error("Error fetching pickup line:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+
+app.get("/fact", async (req, res) => {
+ try {
+ // Fetch a random fact from the Popcat API
+ const response = await axios.get("https://api.popcat.xyz/fact");
+ const data = response.data;
+
+ // Respond with the fact
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ fact: data.fact
+ });
+ } catch (error) {
+ console.error("Error fetching random fact:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+
+
+
+
+
+
+app.get("/instagram", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ error: "Please provide the Instagram URL in the `url` query parameter."
+ });
+ }
+
+ try {
+ const apiUrl = `https://api.paxsenix.biz.id/dl/ig?url=${encodeURIComponent(url)}`;
+ const response = await axios.get(apiUrl);
+
+ if (response.data.ok) {
+ const { thumbnail, url: downloadUrl, type } = response.data.url[0];
+
+ res.status(200).json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ type: type,
+ thumbnail: thumbnail,
+ downloadUrl: downloadUrl
+ });
+ } else {
+ res.status(404).json({
+ creator: "David Cyril",
+ error: "Instagram media could not be retrieved."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching Instagram data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+
+
+// **Remove Background API (Displays Image Directly)**
+app.get("/removebg", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).send("โ Please provide an image URL.");
+ }
+
+ try {
+ // Step 1: Download Image
+ const imageResponse = await axios.get(url, { responseType: "arraybuffer" });
+ const contentType = imageResponse.headers["content-type"];
+
+ if (!imageResponse.data) throw new Error("Failed to download image.");
+
+ // Step 2: Get Upload URL
+ const uploadResponse = await axios.get("https://aibackgroundremover.org/api/get-upload-url", {
+ headers: {
+ "accept": "*/*",
+ "referer": "https://aibackgroundremover.org/"
+ }
+ });
+
+ const { uploadUrl, publicUrl } = uploadResponse.data;
+
+ // Step 3: Upload Image
+ await axios.put(uploadUrl, imageResponse.data, {
+ headers: { "Content-Type": contentType }
+ });
+
+ // Step 4: Request Background Removal
+ const removeResponse = await axios.post("https://aibackgroundremover.org/api/remove-bg",
+ { image: publicUrl },
+ { headers: { "content-type": "application/json" } }
+ );
+
+ const { id } = removeResponse.data;
+
+ // Step 5: Check Processing Status
+ let status;
+ let outputUrl;
+ do {
+ await new Promise(resolve => setTimeout(resolve, 2000));
+ const statusCheck = await axios.get(`https://aibackgroundremover.org/api/check-status?id=${id}`, {
+ headers: { "accept": "*/*" }
+ });
+ status = statusCheck.data.status;
+ outputUrl = statusCheck.data.output;
+ } while (status === "starting" || status === "processing");
+
+ if (status !== "succeeded") throw new Error("Failed to process image.");
+
+ // **Step 6: Redirect to Processed Image**
+ res.redirect(outputUrl);
+
+ } catch (error) {
+ console.error("Remove BG Error:", error.message);
+ res.status(500).send("โ Failed to remove background.");
+ }
+});
+
+
+
+app.get("/apk", async (req, res) => {
+ const { name } = req.query;
+
+ // Check if the `name` parameter is provided
+ if (!name) {
+ return res.status(400).json({
+ status: false,
+ owner: "@DavidCyrilTech",
+ error: "Please provide the app name in the `name` query parameter."
+ });
+ }
+
+ try {
+ // Fetch the APK details using the provided name
+ const apiUrl = `https://bk9.fun/download/apk?id=${encodeURIComponent(name)}`;
+ const response = await axios.get(apiUrl);
+
+ // Check if the API response is successful
+ if (response.data.status) {
+ res.status(200).json({
+ status: true,
+ owner: "@DavidCyrilTech",
+ apk: {
+ name: response.data.BK9.name,
+ lastUpdated: response.data.BK9.lastup,
+ package: response.data.BK9.package,
+ icon: response.data.BK9.icon,
+ downloadLink: response.data.BK9.dllink
+ }
+ });
+ } else {
+ res.status(404).json({
+ status: false,
+ owner: "@DavidCyrilTech",
+ error: "APK not found for the provided name."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching APK details:", error.message);
+ res.status(500).json({
+ status: false,
+ owner: "@DavidCyrilTech",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+
+// Route to fetch and display the image
+app.get("/diffusion", async (req, res) => {
+ const { prompt } = req.query;
+
+ if (!prompt) {
+ return res.status(400).send("Please provide a prompt.");
+ }
+
+ try {
+ // API URL with the provided prompt
+ const apiUrl = `https://api.siputzx.my.id/api/ai/stable-diffusion?prompt=${encodeURIComponent(prompt)}`;
+
+ // Fetch the image from the API
+ const response = await axios.get(apiUrl, { responseType: "arraybuffer" });
+
+ // Set the correct headers to display the image in the browser
+ res.setHeader("Content-Type", "image/png");
+ res.send(response.data);
+ } catch (error) {
+ console.error("Error fetching the image:", error.message);
+ res.status(500).send("Failed to fetch the image. Please try again.");
+ }
+});
+
+
+
+
+
+
+// Translator API
+app.get("/tools/translate", async (req, res) => {
+ const { text, to } = req.query;
+
+ if (!text || !to) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide both text and target language (to)."
+ });
+ }
+
+ try {
+ // Perform translation
+ const result = await translate(text, { to });
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ original_text: text,
+ translated_text: result.text,
+ language: to
+ });
+
+ } catch (error) {
+ console.error("Translation Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to translate text. Please try again later."
+ });
+ }
+});
+
+
+const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));
+
+
+
+// Generate Temporary Email
+async function random_mail() {
+ const link = "https://dropmail.me/api/graphql/web-test-wgq6m5i?query=mutation%20%7BintroduceSession%20%7Bid%2C%20expiresAt%2C%20addresses%20%7Baddress%7D%7D%7D";
+
+ try {
+ let response = await fetch(link);
+ if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
+
+ let data = await response.json();
+ return {
+ email: data.data.introduceSession.addresses[0].address,
+ id: data.data.introduceSession.id,
+ expiresAt: data.data.introduceSession.expiresAt
+ };
+ } catch (error) {
+ console.error("Error generating email:", error);
+ return null;
+ }
+}
+
+// Fetch Inbox Messages
+async function get_mails(id) {
+ const link = `https://dropmail.me/api/graphql/web-test-wgq6m5i?query=query%20(%24id%3A%20ID!)%20%7Bsession(id%3A%24id)%20%7B%20addresses%20%7Baddress%7D%2C%20mails%7BrawSize%2C%20fromAddr%2C%20toAddr%2C%20downloadUrl%2C%20text%2C%20headerSubject%7D%7D%20%7D&variables=%7B%22id%22%3A%22${id}%22%7D`;
+
+ try {
+ let response = await fetch(link);
+ if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
+
+ let data = await response.json();
+ return {
+ inbox: data.data.session.mails || [],
+ count: data.data.session.mails.length || 0
+ };
+ } catch (error) {
+ console.error("Error fetching inbox:", error);
+ return null;
+ }
+}
+
+// **API Endpoints**
+
+// ๐ฏ Generate Temporary Email
+app.get("/temp-mail", async (req, res) => {
+ const emailData = await random_mail();
+ if (!emailData) {
+ return res.status(500).json({ success: false, message: "Failed to generate temporary email." });
+ }
+ res.json({
+ creator: "David Cyril Tech",
+ status: 200,
+ success: true,
+ email: emailData.email,
+ session_id: emailData.id,
+ expires_at: emailData.expiresAt
+ });
+});
+
+// ๐ฉ Fetch Inbox Messages
+app.get("/temp-mail/inbox", async (req, res) => {
+ const { id } = req.query;
+ if (!id) {
+ return res.status(400).json({ success: false, message: "Please provide a valid session ID using `id` parameter." });
+ }
+
+ const inboxData = await get_mails(id);
+ if (!inboxData) {
+ return res.status(500).json({ success: false, message: "Failed to fetch inbox messages." });
+ }
+
+ res.json({
+ creator: "David Cyril Tech",
+ status: 200,
+ success: true,
+ inbox_count: inboxData.count,
+ messages: inboxData.inbox
+ });
+});
+
+
+
+
+
+app.get("/flux", async (req, res) => {
+ const { prompt } = req.query;
+
+ if (!prompt) {
+ return res.status(400).send("Please provide a prompt.");
+ }
+
+ try {
+ // Fetch the image from the Flux API
+ const response = await axios.get(`https://api.siputzx.my.id/api/ai/flux?prompt=${encodeURIComponent(prompt)}`, {
+ responseType: "arraybuffer",
+ });
+
+ // Set the correct headers to display the image in the browser
+ res.setHeader("Content-Type", "image/png");
+ res.send(response.data);
+ } catch (error) {
+ console.error("Error fetching the image:", error.message);
+ res.status(500).send("Failed to fetch the image. Please try again.");
+ }
+});
+
+
+
+// Ephoto API Endpoint Mapping
+
+
+
+
+
+app.get("/githubStalk", async (req, res) => {
+ const { user } = req.query;
+
+ if (!user) {
+ return res.status(400).json({ error: "Please provide a GitHub username." });
+ }
+
+ try {
+ // Fetch data from the API
+ const response = await axios.get(`https://api.siputzx.my.id/api/stalk/github?user=${encodeURIComponent(user)}`);
+ const data = response.data;
+
+ if (!data.status) {
+ return res.status(404).json({ error: "User not found." });
+ }
+
+ // Return the user data as plain JSON
+ res.json({
+ creator: "David Cyril",
+ username: data.data.username,
+ nickname: data.data.nickname,
+ bio: data.data.bio,
+ id: data.data.id,
+ profile_pic: data.data.profile_pic,
+ url: data.data.url,
+ type: data.data.type,
+ location: data.data.location,
+ public_repositories: data.data.public_repo,
+ followers: data.data.followers,
+ following: data.data.following,
+ created_at: data.data.created_at,
+ updated_at: data.data.updated_at
+ });
+ } catch (error) {
+ console.error("Error fetching data:", error.message);
+ res.status(500).json({ error: "Failed to fetch data. Please try again later." });
+ }
+});
+
+
+
+
+const OPENWEATHER_API_KEY = '060a6bcfa19809c2cd4d97a212b19273';
+
+app.get('/weather', async (req, res) => {
+ const { city } = req.query;
+
+ if (!city) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a location using the `city` query parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.openweathermap.org/data/2.5/weather`, {
+ params: {
+ q: city,
+ units: "metric",
+ appid: OPENWEATHER_API_KEY,
+ language: "en"
+ }
+ });
+
+ const weatherData = response.data;
+ const result = {
+ creator: "David Cyril",
+ success: true,
+ data: {
+ location: weatherData.name,
+ country: weatherData.sys.country,
+ weather: weatherData.weather[0].main,
+ description: weatherData.weather[0].description,
+ temperature: `${weatherData.main.temp} ยฐC`,
+ feels_like: `${weatherData.main.feels_like} ยฐC`,
+ pressure: `${weatherData.main.pressure} hPa`,
+ humidity: `${weatherData.main.humidity}%`,
+ wind_speed: `${weatherData.wind.speed} m/s`,
+ coordinates: {
+ latitude: weatherData.coord.lat,
+ longitude: weatherData.coord.lon
+ }
+ }
+ };
+
+ res.status(200).json(result);
+ } catch (error) {
+ console.error("Error fetching weather data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch weather data. Please try again later."
+ });
+ }
+});
+
+
+
+
+app.get('/googleimage', async (req, res) => {
+ const { query } = req.query;
+
+ if (!query) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `query` parameter. Example: /gimage?query=cats"
+ });
+ }
+
+ try {
+ // Fetch data from the provided API
+ const response = await axios.get(`https://api.vreden.web.id/api/gimage?query=${encodeURIComponent(query)}`);
+ const data = response.data;
+
+ if (data.status !== 200 || !data.result || data.result.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No images found for the given query."
+ });
+ }
+
+ // Construct response
+ const responseData = {
+ creator: "David Cyril",
+ success: true,
+ query: query,
+ results: data.result
+ };
+
+ res.status(200).json(responseData);
+ } catch (error) {
+ console.error("Error fetching Google Image Search data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while fetching image search data. Please try again later."
+ });
+ }
+});
+
+app.get('/ffstalk', async (req, res) => {
+ const { id } = req.query;
+
+ if (!id) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a Free Fire account ID using the `id` query parameter. Example: /ffstalk?id=12345678"
+ });
+ }
+
+ try {
+ // Fetch data from the provided API
+ const response = await axios.get(`https://api.vreden.web.id/api/ffstalk?id=${id}`);
+ const data = response.data;
+
+ if (data.status !== 200) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No account found with the provided ID."
+ });
+ }
+
+ const result = data.result;
+
+ // Construct response
+ const responseData = {
+ creator: "David Cyril",
+ success: true,
+ account: {
+ id: result.account.id,
+ name: result.account.name,
+ level: result.account.level,
+ xp: result.account.xp,
+ region: result.account.region,
+ likes: result.account.like,
+ bio: result.account.bio,
+ created_at: result.account.create_time,
+ last_login: result.account.last_login,
+ honor_score: result.account.honor_score,
+ booyah_pass: result.account.booyah_pass,
+ booyah_pass_badge: result.account.booyah_pass_badge,
+ evo_access_badge: result.account.evo_access_badge,
+ equipped_title: result.account.equipped_title,
+ BR_points: result.account.BR_points,
+ CS_points: result.account.CS_points,
+ },
+ pet_info: {
+ name: result.pet_info.name,
+ level: result.pet_info.level,
+ type: result.pet_info.type,
+ xp: result.pet_info.xp,
+ },
+ guild: {
+ name: result.guild.name,
+ id: result.guild.id,
+ level: result.guild.level,
+ member_count: result.guild.member,
+ capacity: result.guild.capacity,
+ },
+ guild_leader: {
+ id: result.ketua_guild.id,
+ name: result.ketua_guild.name,
+ level: result.ketua_guild.level,
+ xp: result.ketua_guild.xp,
+ likes: result.ketua_guild.like,
+ last_login: result.ketua_guild.last_login,
+ BR_points: result.ketua_guild.BR_points,
+ CS_points: result.ketua_guild.CS_points,
+ }
+ };
+
+ res.status(200).json(responseData);
+ } catch (error) {
+ console.error("Error fetching Free Fire data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while fetching Free Fire data. Please try again later."
+ });
+ }
+});
+
+
+
+
+// Search Emoji Endpoint
+app.get("/search/semoji", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `q` parameter.",
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://bk9.fun/search/semoji?q=${encodeURIComponent(text)}`);
+ const { BK9 } = response.data;
+
+ if (!BK9 || BK9.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No emojis found for the provided query.",
+ });
+ }
+
+ // Format the response
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: BK9,
+ });
+ } catch (error) {
+ console.error("Error fetching emoji search results:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later.",
+ });
+ }
+});
+
+
+
+// Steam Search Endpoint
+app.get("/search/steam", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `q` parameter.",
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://bk9.fun/search/Steam?q=${encodeURIComponent(text)}`);
+ const { BK9 } = response.data;
+
+ if (!BK9 || BK9.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No games found for the provided query.",
+ });
+ }
+
+ // Format the response
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: BK9.map((game) => ({
+ title: game.title,
+ img: game.img,
+ link: game.link,
+ release: game.release.trim(),
+ price: game.price || "Free / Not Listed",
+ rating: game.rating || "No Ratings Yet",
+ })),
+ });
+ } catch (error) {
+ console.error("Error fetching Steam search results:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later.",
+ });
+ }
+});
+
+
+
+// Movie Search Endpoint
+app.get("/zoom/search", async (req, res) => {
+ const { query } = req.query;
+ if (!query) {
+ return res.status(400).json({
+ status: false,
+ message: "Please provide a movie query.",
+ });
+ }
+
+ try {
+ const url = `https://zoom.lk/?s=${query}`;
+ const response = await axios.get(url);
+ const $ = cheerio.load(response.data);
+ const movies = [];
+
+ $("div.td-pb-span8.td-main-content > div > div.td_module_16.td_module_wrap.td-animation-stack").each((c, d) => {
+ const title = $(d).find("div.item-details > h3 > a").text();
+ const link = $(d).find("div.item-details > h3 > a").attr("href");
+ const image = $(d).find("div.td-module-thumb > img").attr("src");
+ const author = $(d).find("div.item-details > div > span > a").text();
+ const desc = $(d).find("div.item-details > div.td-excerpt").text();
+ const comments = $(d).find("div.item-details > div > span.td-module-comments a").text();
+
+ movies.push({ title, link, image, author, desc, comments });
+ });
+
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ result: movies.length ? movies : "No movies found",
+ });
+ } catch (error) {
+ res.status(500).json({
+ status: false,
+ message: "Failed to fetch search results.",
+ error: error.message,
+ });
+ }
+});
+
+// Movie Details & Download Endpoint
+app.get("/zoom/movie", async (req, res) => {
+ const { url } = req.query;
+ if (!url) {
+ return res.status(400).json({
+ status: false,
+ message: "Please provide a valid movie page URL.",
+ });
+ }
+
+ try {
+ const response = await axios.get(url);
+ const $ = cheerio.load(response.data);
+
+ const title = $("#tdi_56 h1").text();
+ const author = $("div.vc_column_inner.tdi_64 a").text();
+ const view = $("div.vc_column_inner.tdi_67 span").text();
+ const date = $("div.vc_column_inner.tdi_70 time").text();
+ const size = $("div.tdb_single_content p a small").text();
+ const dl_link = $("div.tdb-block-inner p a").attr("href");
+
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ result: {
+ title,
+ author,
+ view,
+ date,
+ size,
+ dl_link,
+ },
+ });
+ } catch (error) {
+ res.status(500).json({
+ status: false,
+ message: "Failed to fetch movie details.",
+ error: error.message,
+ });
+ }
+});
+
+
+
+
+
+// Function to search for movies
+async function firemovie(query) {
+ const searchUrl = `https://firemovieshub.com/?s=${query}`;
+ try {
+ const response = await axios.get(searchUrl);
+ const $ = cheerio.load(response.data);
+ const searchResults = [];
+
+ $('.result-item').each((i, elem) => {
+ const title = $(elem).find('.title a').text().trim();
+ const link = $(elem).find('.title a').attr('href');
+ const img = $(elem).find('img').attr('src') || 'https://via.placeholder.com/100x150?text=No+Image';
+
+ searchResults.push({ title, link, img });
+ });
+
+ if (searchResults.length === 0) {
+ return { error: 'No movies found for this query.' };
+ }
+
+ return { searchResults };
+ } catch (error) {
+ console.error('Error searching movies:', error);
+ return { error: 'Failed to fetch search results.' };
+ }
+}
+
+// API Endpoint for Movie Search
+app.get('/firemovie/search', async (req, res) => {
+ const query = req.query.query;
+
+ if (!query) {
+ return res.status(400).json({ error: 'Query parameter is required.' });
+ }
+
+ const result = await firemovie(query);
+ if (result.error) {
+ return res.status(500).json(result);
+ }
+
+ res.json(result);
+});
+
+
+
+
+app.get("/youtube/search", async (req, res) => {
+ const { query } = req.query;
+
+ if (!query) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "Please provide a search query."
+ });
+ }
+
+ try {
+ // Perform the YouTube search
+ const results = await ytSearch(query);
+
+ if (!results.videos.length) {
+ return res.json({
+ creator: "David Cyril",
+ status: false,
+ message: "No results found."
+ });
+ }
+
+ // Extracting relevant data
+ const videos = results.videos.slice(0, 10).map(video => ({
+ title: video.title,
+ videoId: video.videoId,
+ url: video.url,
+ thumbnail: video.thumbnail,
+ views: video.views,
+ duration: video.duration.timestamp,
+ published: video.ago
+ }));
+
+ // Send response
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ results: videos
+ });
+
+ } catch (error) {
+ console.error("Error fetching YouTube search:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "An error occurred while fetching YouTube search results."
+ });
+ }
+});
+
+
+// Your searchMovies function
+async function firemovies(query) {
+ const searchUrl = `https://firemovieshub.com/?s=${query}`;
+ try {
+ const response = await axios.get(searchUrl);
+ const $ = cheerio.load(response.data);
+ const searchResults = [];
+
+ $('.result-item').each((i, elem) => {
+ const title = $(elem).find('.title a').text().trim();
+ const link = $(elem).find('.title a').attr('href');
+ const img = $(elem).find('img').attr('src') || 'https://via.placeholder.com/100x150?text=No+Image';
+
+ searchResults.push({ title, link, img });
+ });
+
+ if (searchResults.length === 0) {
+ return { error: 'No movies found for this query.' };
+ }
+
+ return { searchResults };
+ } catch (error) {
+ console.error('Error searching movies:', error);
+ return { error: 'Failed to fetch search results.' };
+ }
+}
+
+// API Endpoint for Movie Search
+app.get('/firemovies/search', async (req, res) => {
+ const query = req.query.query;
+
+ if (!query) {
+ return res.status(400).json({ error: 'Query parameter is required.' });
+ }
+
+ const result = await firemovies(query);
+ if (result.error) {
+ return res.status(500).json(result);
+ }
+
+ res.json(result);
+});
+
+
+
+
+// Supported audio formats
+const audioFormats = ["mp3", "m4a", "webm", "aac", "flac", "opus", "ogg", "wav"];
+
+// Function to check download progress
+async function checkProgress(progressId) {
+ const config = {
+ method: "GET",
+ url: `https://p.oceansaver.in/ajax/progress.php?id=${progressId}`,
+ headers: {
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
+ },
+ };
+
+ while (true) {
+ const response = await axios.request(config);
+ if (response.data?.success && response.data.progress === 1000) {
+ return response.data.download_url;
+ }
+ await new Promise((resolve) => setTimeout(resolve, 5000)); // Retry every 5 seconds
+ }
+}
+
+// Function to fetch YouTube MP3 Download Link
+async function fetchMp3Download(videoUrl) {
+ const config = {
+ method: "GET",
+ url: `https://p.oceansaver.in/ajax/download.php?format=mp3&url=${encodeURIComponent(videoUrl)}&api=dfcb6d76f2f6a9894gjkege8a4ab232222`,
+ headers: {
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
+ },
+ };
+
+ const response = await axios.request(config);
+ if (response.data?.success) {
+ const { id, title, info } = response.data;
+ const mp3Url = await checkProgress(id);
+ return { title, thumbnail: info.image, mp3Url };
+ } else {
+ throw new Error("Failed to fetch MP3 download link.");
+ }
+}
+
+// Function to extract YouTube video ID
+function getYouTubeID(youtubeUrl) {
+ const match = youtubeUrl.match(/(?:youtube\.com\/(?:.*[?&]v=)|youtu\.be\/)([^"&?/\s]{11})/);
+ return match ? match[1] : null;
+}
+
+// YouTube Play Command API
+app.get("/play", async (req, res) => {
+ const { query } = req.query;
+
+ if (!query) {
+ return res.status(400).json({
+ creator: CREATOR,
+ status: false,
+ message: "Please provide a search query.",
+ });
+ }
+
+ try {
+ // Search YouTube for the song
+ const searchResults = await ytSearch(query);
+
+ if (!searchResults.videos.length) {
+ return res.json({
+ creator: CREATOR,
+ status: false,
+ message: "No results found.",
+ });
+ }
+
+ // Get first video result
+ const firstResult = searchResults.videos[0];
+
+ // Fetch MP3 download link
+ const mp3Data = await fetchMp3Download(firstResult.url);
+ const videoId = getYouTubeID(firstResult.url);
+
+ // Response JSON
+ res.json({
+ creator: CREATOR,
+ status: true,
+ result: {
+ title: firstResult.title,
+ video_url: firstResult.url,
+ thumbnail: firstResult.thumbnail || `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`,
+ duration: firstResult.duration.timestamp,
+ views: firstResult.views,
+ published: firstResult.ago,
+ download_url: mp3Data.mp3Url, // Direct MP3 download link
+ },
+ });
+ } catch (error) {
+ console.error("Error processing YouTube play request:", error.message);
+ res.status(500).json({
+ creator: CREATOR,
+ status: false,
+ message: "Failed to process request. Please try again.",
+ });
+ }
+});
+
+
+
+
+app.get("/youtube/mp4", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "Please provide a valid YouTube URL."
+ });
+ }
+
+ try {
+ // Fetch video details from the external API
+ const response = await axios.get(`https://bk9.fun/download/youtube2?url=${encodeURIComponent(url)}`);
+ const data = response.data.BK9[0];
+
+ if (!data || !data.mediaLink) {
+ return res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "Failed to fetch download link. Please try again later."
+ });
+ }
+
+ // Construct the response in the required format
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ result: {
+ title: data.title || "Unknown Title",
+ thumbnail: `https://img.youtube.com/vi/${getYouTubeVideoId(url)}/hqdefault.jpg`, // Get YouTube thumbnail
+ url: data.mediaLink
+ }
+ });
+
+ } catch (error) {
+ console.error("Error fetching YouTube MP4 data:", error.message);
+ return res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "An error occurred while processing your request."
+ });
+ }
+});
+
+// Extract YouTube video ID from URL
+function getYouTubeVideoId(url) {
+ const match = url.match(/(?:youtu\.be\/|youtube\.com\/(?:.*v=|.*\/)([^&?#]+))/);
+ return match ? match[1] : "default";
+}
+
+
+
+
+// Facebook Video Downloader
+app.get("/download/aio", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a video URL using the `url` parameter.",
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://bk9.fun/download/alldownload?url=${encodeURIComponent(url)}`);
+ const { BK9 } = response.data;
+
+ if (!BK9 || (!BK9.low && !BK9.high)) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Unable to fetch the download links. Please check the video URL.",
+ });
+ }
+
+ // Respond with download links
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ video: {
+ title: BK9.title || "Unknown Title",
+ low_quality: BK9.low,
+ high_quality: BK9.high,
+ },
+ });
+ } catch (error) {
+ console.error("Error fetching Xnxx Downloader links:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later.",
+ });
+ }
+});
+
+
+
+// Sticker Search Endpoint
+app.get("/search/sticker", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `text` parameter.",
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.maskser.me/api/search/sticker?text=${encodeURIComponent(text)}`);
+ const { result } = response.data;
+
+ if (!result || !result.sticker_url || result.sticker_url.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No stickers found for the provided query.",
+ });
+ }
+
+ // Format the response
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: {
+ title: result.title,
+ stickers: result.sticker_url,
+ },
+ });
+ } catch (error) {
+ console.error("Error fetching sticker search results:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later.",
+ });
+ }
+});
+
+
+// SoundCloud Search Endpoint
+app.get("/search/soundcloud", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `message` parameter.",
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.agatz.xyz/api/soundcloud?message=${encodeURIComponent(text)}`);
+ const { data } = response.data;
+
+ if (!data || data.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No results found for the provided query.",
+ });
+ }
+
+ // Format the response
+ const results = data.map((item) => ({
+ title: item.judul,
+ link: item.link,
+ }));
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: results,
+ });
+ } catch (error) {
+ console.error("Error fetching SoundCloud results:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later.",
+ });
+ }
+});
+
+
+
+// Wallpaper Search Endpoint
+app.get("/search/wallpaper", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `text` parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.maskser.me/api/search/wallpaper?text=${encodeURIComponent(text)}`);
+ const { result } = response.data;
+
+ if (!result || result.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No wallpapers found for the provided query."
+ });
+ }
+
+ // Format the response
+ const wallpapers = result.map((item) => ({
+ title: item.title || "Unknown Title",
+ type: item.type || "Unknown Type",
+ source: item.source || "Unknown Source",
+ image: item.image
+ }));
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: wallpapers
+ });
+ } catch (error) {
+ console.error("Error fetching wallpapers:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later."
+ });
+ }
+});
+
+
+
+// Pinterest Search Endpoint
+app.get("/search/pinterest", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `text` parameter.",
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://itzpire.com/search/pinterest?text=${encodeURIComponent(text)}`);
+ const { data } = response.data;
+
+ if (!data || data.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No results found for the provided query.",
+ });
+ }
+
+ // Format the response
+ const results = data.map((item) => ({
+ uploader: item.upload_by,
+ fullName: item.fullname,
+ followers: item.followers,
+ caption: item.caption,
+ image: item.image,
+ source: item.source,
+ }));
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: results,
+ });
+ } catch (error) {
+ console.error("Error fetching Pinterest results:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later.",
+ });
+ }
+});
+
+
+
+// List of supported models
+const models = [
+ "deepseek-ai/DeepSeek-V3",
+ "deepseek-ai/DeepSeek-R1",
+ "mistralai/Mistral-Small-24B-Instruct-2501",
+ "deepseek-ai/deepseek-llm-67b-chat",
+ "databricks/dbrx-instruct",
+ "Qwen/QwQ-32B-Preview",
+ "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO"
+];
+
+
+const generateUserId = () => Math.floor(100000 + Math.random() * 900000);
+
+// **API Endpoint to Chat with AI**
+app.get("/ai/blackbox", async (req, res) => {
+ const { text, model } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ // Check if model is valid, otherwise use default
+ const selectedModel = models.includes(model) ? model : models[0];
+ const userId = generateUserId(); // Generate random User ID
+
+ try {
+ const response = await axios.post(BLACKBOX_API, {
+ messages: [{ content: text, role: "user" }],
+ model: selectedModel,
+ max_tokens: 1024
+ }, {
+ headers: { "Content-Type": "application/json" }
+ });
+
+ // Get AI Response
+ const aiResponse = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ model: selectedModel,
+ userId,
+ response: aiResponse
+ });
+ } catch (error) {
+ console.error("Error fetching AI response:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while fetching the AI response."
+ });
+ }
+});
+
+// **API Endpoint to List Available Models**
+app.get("/ai/blackbox/models", (req, res) => {
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ available_models: models
+ });
+});
+
+
+
+// Function to get CSRF token and cookies
+async function getToken() {
+ try {
+ const response = await axios.get("https://www.gempaytopup.com");
+ const cookies = response.headers["set-cookie"];
+ const joinedCookies = cookies ? cookies.join("; ") : null;
+
+ const csrfTokenMatch = response.data.match(//);
+ const csrfToken = csrfTokenMatch ? csrfTokenMatch[1] : null;
+
+ if (!csrfToken || !joinedCookies) {
+ throw new Error("Failed to retrieve CSRF token or cookies.");
+ }
+
+ return { csrfToken, joinedCookies };
+ } catch (error) {
+ console.error("โ Error fetching CSRF token or cookies:", error.message);
+ throw error;
+ }
+}
+
+// Function to fetch Mobile Legends profile data
+async function mlStalk(userId, zoneId) {
+ try {
+ const { csrfToken, joinedCookies } = await getToken();
+
+ const payload = { uid: userId, zone: zoneId };
+ const { data } = await axios.post(
+ "https://www.gempaytopup.com/stalk-ml",
+ payload, {
+ headers: {
+ "X-CSRF-Token": csrfToken,
+ "Content-Type": "application/json",
+ "Cookie": joinedCookies,
+ },
+ }
+ );
+
+ return data;
+ } catch (error) {
+ console.error("โ Error fetching ML data:", error.message);
+ throw error;
+ }
+}
+
+// API Endpoint
+app.get("/game/mlstalk", async (req, res) => {
+ const { uid, zone } = req.query;
+
+ if (!uid || !zone) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide both 'uid' and 'zone' parameters."
+ });
+ }
+
+ try {
+ const result = await mlStalk(uid, zone);
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ data: result
+ });
+ } catch (error) {
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to retrieve Mobile Legends profile data."
+ });
+ }
+});
+
+app.get("/ai/gpt4", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query.",
+ });
+ }
+
+ try {
+ const apiUrl = `https://api.siputzx.my.id/api/ai/deepseek-llm-67b-chat?content=${encodeURIComponent(text)}`;
+
+ // Fetch AI response
+ const response = await axios.get(apiUrl);
+ const { status, data } = response.data;
+
+ if (!status || !data) {
+ return res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch AI response. Please try again later.",
+ });
+ }
+
+ // Return AI response
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ message: data,
+ });
+ } catch (error) {
+ console.error("Error fetching AI response:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while fetching the AI response.",
+ });
+ }
+});
+
+
+
+
+// XVideo Downloader Endpoint
+app.get("/search/xvideo", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `message` parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.agatz.xyz/api/xvideo?message=${encodeURIComponent(text)}`);
+ const { data } = response.data;
+
+ if (!data || data.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No results found for the provided query."
+ });
+ }
+
+ // Format the response
+ const results = data.map((video) => ({
+ title: video.title,
+ duration: video.duration,
+ quality: video.quality || "Unknown",
+ thumbnail: video.thumb,
+ url: video.url
+ }));
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: results
+ });
+ } catch (error) {
+ console.error("Error fetching XVideo results:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later."
+ });
+ }
+});
+
+
+
+// Spotify Search Endpoint
+app.get("/search/spotify", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `message` parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.agatz.xyz/api/spotify?message=${encodeURIComponent(text)}`);
+ const { data } = response.data;
+
+ if (!data || data.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No results found for the provided query."
+ });
+ }
+
+ // Format the response
+ const results = data.map((track) => ({
+ trackNumber: track.trackNumber,
+ trackName: track.trackName,
+ artistName: track.artistName,
+ albumName: track.albumName,
+ duration: track.duration,
+ previewUrl: track.previewUrl || "Not available",
+ externalUrl: track.externalUrl
+ }));
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: results
+ });
+ } catch (error) {
+ console.error("Error fetching Spotify results:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later."
+ });
+ }
+});
+
+
+
+// Playstore Search Endpoint
+app.get("/search/playstore", async (req, res) => {
+ const { q } = req.query;
+
+ if (!q) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search query using the `q` parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://bk9.fun/search/playstore?q=${encodeURIComponent(q)}`);
+ const { BK9 } = response.data;
+
+ if (!BK9) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No results found for the provided query."
+ });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: {
+ title: BK9.title,
+ summary: BK9.summary,
+ installs: BK9.installs,
+ score: BK9.score,
+ price: BK9.price,
+ size: BK9.size,
+ androidVersion: BK9.androidVersion,
+ developer: BK9.developer,
+ released: BK9.released,
+ updated: BK9.updated,
+ version: BK9.version,
+ icon: BK9.icon,
+ screenshots: BK9.screenshots,
+ url: BK9.url
+ }
+ });
+ } catch (error) {
+ console.error("Error fetching Playstore data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later."
+ });
+ }
+});
+
+
+
+
+app.get('/quran', async (req, res) => {
+ const { surah } = req.query;
+
+ if (!surah) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide the surah name or number using the `surah` query parameter. Example: /quran?surah=1 or /quran?surah=Al-Fatiha"
+ });
+ }
+
+ try {
+ // Fetch all surah data
+ const surahListResponse = await axios.get('https://quran-endpoint.vercel.app/quran');
+ const surahList = surahListResponse.data.data;
+
+ // Find the requested surah
+ const surahData = surahList.find(s =>
+ s.number === Number(surah) ||
+ s.asma.ar.short.toLowerCase() === surah.toLowerCase() ||
+ s.asma.en.short.toLowerCase() === surah.toLowerCase()
+ );
+
+ if (!surahData) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: `No surah found with the name or number "${surah}"`
+ });
+ }
+
+ // Fetch surah details
+ const surahDetailsResponse = await axios.get(`https://quran-endpoint.vercel.app/quran/${surahData.number}`);
+ const surahDetails = surahDetailsResponse.data.data;
+
+ // Construct the result
+ const result = {
+ creator: "David Cyril",
+ success: true,
+ surah: {
+ number: surahDetails.number,
+ name: {
+ arabic: surahDetails.asma.ar.long,
+ english: surahDetails.asma.en.long
+ },
+ type: surahDetails.type.en,
+ ayahCount: surahDetails.ayahCount,
+ tafsir: {
+ id: surahDetails.tafsir.id
+ },
+ recitation: surahDetails.recitation.full
+ }
+ };
+
+ res.status(200).json(result);
+ } catch (error) {
+ console.error("Error fetching Quran data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while fetching Quran data. Please try again later."
+ });
+ }
+});
+
+
+
+
+app.get('/bible', async (req, res) => {
+ const { reference } = req.query;
+
+ if (!reference) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a reference using the `reference` query parameter. Example: /bible?reference=john 3:16"
+ });
+ }
+
+ try {
+ // Fetch Bible content from the external Bible API
+ const response = await axios.get(`https://bible-api.com/${encodeURIComponent(reference)}`);
+ const data = response.data;
+
+ // Format the response
+ const result = {
+ creator: "David Cyril",
+ success: true,
+ reference: data.reference,
+ translation: data.translation_name,
+ verses_count: data.verses.length,
+ text: data.text
+ };
+
+ res.status(200).json(result);
+ } catch (error) {
+ console.error("Error fetching Bible data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while fetching Bible content. Please check the reference and try again."
+ });
+ }
+});
+
+
+
+
+
+app.get("/pinterest", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({ error: "Please provide a Pinterest URL." });
+ }
+
+ try {
+ // Fetch data from the API
+ const response = await axios.get(`https://api.agatz.xyz/api/pinterest`, {
+ params: { url }
+ });
+ const data = response.data;
+
+ if (data.status !== 200) {
+ return res.status(500).json({ error: "Failed to fetch video." });
+ }
+
+ // Return the API response
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ original_url: data.data.url,
+ download_url: data.data.result
+ });
+ } catch (error) {
+ console.error("Error fetching Pinterest video:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+
+app.get("/shortenUrl", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({ error: "Please provide a URL to shorten." });
+ }
+
+ try {
+ // Fetch data from the URL shortener API
+ const response = await axios.get(`https://api.paxsenix.biz.id/tools/urlshorter?url=${encodeURIComponent(url)}`);
+ const data = response.data;
+
+ if (!data.ok) {
+ return res.status(500).json({ error: "Failed to shorten the URL. Please try again." });
+ }
+
+ // Return shortened URL details
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ original_url: url,
+ shortened_url: data.url
+ });
+ } catch (error) {
+ console.error("Error shortening URL:", error.message);
+ res.status(500).json({ error: "Failed to shorten URL. Please try again later." });
+ }
+});
+
+
+
+
+app.get("/blackbox", async (req, res) => {
+ const { q } = req.query;
+
+ if (!q) {
+ return res.status(400).json({ error: "Please provide a query using the 'q' parameter." });
+ }
+
+ try {
+ // Send a request to the Blackbox API
+ const response = await axios.get(`https://bk9.fun/ai/blackbox?q=${encodeURIComponent(q)}`);
+ const data = response.data;
+
+ if (!data.status) {
+ return res.status(500).json({ error: "Failed to fetch response from Blackbox ." });
+ }
+
+ // Return the API response
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ response: data.BK9
+ });
+ } catch (error) {
+ console.error("Error fetching Blackbox response:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+
+app.get("/couplepp", async (req, res) => {
+ try {
+ // Send request to the API
+ const response = await axios.get(`https://api.maskser.me/api/randomgambar/couplepp`);
+ const data = response.data;
+
+ if (!data.status) {
+ return res.status(500).json({ error: "Failed to fetch couple profile pictures." });
+ }
+
+ // Return the API response
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ male: data.result.male,
+ female: data.result.female
+ });
+ } catch (error) {
+ console.error("Error fetching couple profile pictures:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+
+
+
+app.get("/imgscan", async (req, res) => {
+
+ const q = "who is this"
+ const { url } = req.query;
+ if (!url || !q) {
+ return res.status(400).json({ error: "Please provide both 'url'." });
+ }
+
+ try {
+ // Send request to Gemini Image API
+ const response = await axios.get(`https://bk9.fun/ai/geminiimg`, {
+ params: { url, q }
+ });
+ const data = response.data;
+
+ if (!data.status) {
+ return res.status(500).json({ error: "Failed to fetch response from Gemini Image ." });
+ }
+
+ // Return the API response
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ result: data.BK9
+ });
+ } catch (error) {
+ console.error("Error fetching Gemini Image response:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+
+app.get("/twitter", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({ error: "Please provide a Twitter post URL." });
+ }
+
+ try {
+ // Fetch data from the API
+ const response = await axios.get(`https://api.agatz.xyz/api/twitter?url=${encodeURIComponent(url)}`);
+ const data = response.data;
+
+ if (data.status !== 200) {
+ return res.status(404).json({ error: "Unable to fetch Twitter media. Please check the URL." });
+ }
+
+ // Return the extracted details
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ description: data.data.desc,
+ thumbnail: data.data.thumb,
+ video_sd: data.data.video_sd,
+ video_hd: data.data.video_hd,
+ audio: data.data.audio
+ });
+ } catch (error) {
+ console.error("Error fetching data:", error.message);
+ res.status(500).json({ error: "Failed to fetch data. Please try again later." });
+ }
+});
+
+
+
+app.get("/gdrive", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({ error: "Please provide a Google Drive URL." });
+ }
+
+ try {
+ // Fetch the download link from the API
+ const response = await axios.get(`https://api.siputzx.my.id/api/d/gdrive?url=${encodeURIComponent(url)}`);
+ const data = response.data;
+
+ if (!data.status) {
+ return res.status(404).json({ error: "Unable to fetch the download link. Please check the URL." });
+ }
+
+ // Return the extracted details as plain JSON
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ name: data.data.name,
+ download_link: data.data.download
+ });
+ } catch (error) {
+ console.error("Error fetching data:", error.message);
+ res.status(500).json({ error: "Failed to fetch data. Please try again later." });
+ }
+});
+
+// Endpoint for Dare
+app.get("/dare", async (req, res) => {
+ try {
+ const response = await axios.get("https://api.truthordarebot.xyz/v1/dare");
+ const data = response.data;
+
+ if (!data || !data.question) {
+ return res.status(500).json({ error: "Unable to fetch dare question." });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ type: "DARE",
+ question: data.question
+ });
+ } catch (error) {
+ console.error("Error fetching dare question:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+// Endpoint for Truth
+app.get("/truth", async (req, res) => {
+ try {
+ const response = await axios.get("https://api.truthordarebot.xyz/v1/truth");
+ const data = response.data;
+
+ if (!data || !data.question) {
+ return res.status(500).json({ error: "Unable to fetch truth question." });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ type: "TRUTH",
+ question: data.question
+ });
+ } catch (error) {
+ console.error("Error fetching truth question:", error.message);
+ res.status(500).json({ error: "An error occurred. Please try again later." });
+ }
+});
+
+
+
+
+app.get("/tiktokStalk", async (req, res) => {
+ const { q } = req.query;
+
+ // Check if the `q` parameter (username) is provided
+ if (!q) {
+ return res.status(400).json({
+ status: false,
+ creator: "David Cyril",
+ error: "Please provide a TikTok username in the `q` query parameter."
+ });
+ }
+
+ try {
+ // Call the BK9 TikTok stalker API
+ const apiUrl = `https://bk9.fun/stalk/tiktok?q=${encodeURIComponent(q)}`;
+ const response = await axios.get(apiUrl);
+
+ // Check if the API response is successful
+ if (response.data.status) {
+ res.status(200).json({
+ status: true,
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ profile: response.data.BK9.profile,
+ name: response.data.BK9.name,
+ username: response.data.BK9.username,
+ followers: response.data.BK9.followers,
+ following: response.data.BK9.following,
+ description: response.data.BK9.desc || "No description provided",
+ bio: response.data.BK9.bio || "No bio provided",
+ likes: response.data.BK9.likes
+ });
+ } else {
+ res.status(404).json({
+ status: false,
+ creator: "David Cyril",
+ error: "TikTok user not found."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching TikTok user details:", error.message);
+ res.status(500).json({
+ status: false,
+ creator: "David Cyril",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+// Bitly Shortener
+app.get("/bitly", async (req, res) => {
+ const { link } = req.query;
+
+ if (!link) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a URL using the `link` query parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.maskser.me/api/linkshort/bitly?link=${encodeURIComponent(link)}`);
+ const { result } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ original_url: link,
+ shortened_url: result
+ });
+ } catch (error) {
+ console.error("Error creating Bitly link:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to create a Bitly link. Please try again later."
+ });
+ }
+});
+
+// Cuttly Shortener
+app.get("/cuttly", async (req, res) => {
+ const { link } = req.query;
+
+ if (!link) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a URL using the `link` query parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.maskser.me/api/linkshort/cuttly?link=${encodeURIComponent(link)}`);
+ const { result } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ original_url: link,
+ shortened_url: result
+ });
+ } catch (error) {
+ console.error("Error creating Cuttly link:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to create a Cuttly link. Please try again later."
+ });
+ }
+});
+
+
+app.get("/tinyurl", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a URL using the `url` query parameter."
+ });
+ }
+
+ try {
+ // Call the TinyURL API
+ const response = await axios.get(`https://tinyurl.com/api-create.php?url=${encodeURIComponent(url)}`);
+ const tinyUrl = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ original_url: url,
+ shortened_url: tinyUrl
+ });
+ } catch (error) {
+ console.error("Error creating TinyURL:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to create a TinyURL. Please try again later."
+ });
+ }
+});
+
+
+app.get("/ai/dalle", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text using the `text` query parameter."
+ });
+ }
+
+ try {
+ // Call the external DALLยทE API to create a job
+ const response = await axios.get(`https://api.paxsenix.biz.id/ai-image/dalle?text=${encodeURIComponent(text)}`);
+ const { jobId } = response.data;
+
+ if (!jobId) {
+ return res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to create a DALLยทE job. Please try again."
+ });
+ }
+
+ // Poll the job status and fetch the result
+ const result = await pollDalleJob(jobId);
+
+ if (result && result.url) {
+ // Set the Content-Type for image display and return the image
+ const imageResponse = await axios.get(result.url, { responseType: "arraybuffer" });
+ res.set("Content-Type", "image/png");
+ return res.send(imageResponse.data);
+ }
+
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch DALLยทE."
+ });
+ } catch (error) {
+ console.error("Error fetching DALLยทE response:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch data. Please try again later."
+ });
+ }
+});
+
+// Helper function to poll the job status
+async function pollDalleJob(jobId, interval = 2000, maxAttempts = 15) {
+ let attempts = 0;
+
+ while (attempts < maxAttempts) {
+ try {
+ const response = await axios.get(`https://api.paxsenix.biz.id/task/${jobId}`);
+ const { status, url } = response.data;
+
+ if (status === "done") {
+ return { url };
+ }
+ } catch (error) {
+ console.error("Error polling DALLยทE job:", error.message);
+ }
+
+ attempts++;
+ await new Promise((resolve) => setTimeout(resolve, interval)); // Wait before next attempt
+ }
+
+ return null; // Return null if job isn't completed after max attempts
+}
+
+
+app.get("/ai/searchgpt", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text using the `text` query parameter."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.paxsenix.biz.id/ai/searchgpt?text=${encodeURIComponent(text)}`);
+ const { message } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ message
+ });
+ } catch (error) {
+ console.error("Error fetching SearchGPT response:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch data. Please try again later."
+ });
+ }
+});
+
+
+
+
+app.get("/ssweb", async (req, res) => {
+ const { url, type = "tablet" } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide the URL to screenshot using the `url` query parameter."
+ });
+ }
+
+ try {
+ // Fetch the screenshot from the external API
+ const response = await axios.get(`https://api.vreden.web.id/api/ssweb?url=${encodeURIComponent(url)}&type=${type}`, {
+ responseType: "arraybuffer"
+ });
+
+ // Set the appropriate Content-Type and send the image data directly
+ res.set("Content-Type", "image/png"); // Assuming the screenshot is in PNG format
+ res.send(response.data);
+ } catch (error) {
+ console.error("Error fetching website screenshot:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch the screenshot. Please try again later."
+ });
+ }
+});
+
+
+
+
+
+
+
+app.get("/lyrics", async (req, res) => {
+ const { t: title, a: artist } = req.query;
+
+ if (!title || !artist) {
+ return res.status(400).json({
+ creator: "David Cyril Tech",
+ error: "Please provide both the title (`t`) and artist (`a`) of the song."
+ });
+ }
+
+ try {
+ const apiUrl = `https://api.paxsenix.biz.id/lyrics/genius?t=${encodeURIComponent(title)}&a=${encodeURIComponent(artist)}`;
+ const response = await axios.get(apiUrl);
+
+ if (response.data.ok) {
+ res.status(200).json({
+ creator: "David Cyril Tech",
+ title: title,
+ artist: artist,
+ lyrics: response.data.lyrics || "Lyrics not available",
+ });
+ } else {
+ res.status(404).json({
+ creator: "David Cyril Tech",
+ error: "Lyrics not found in the database."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching lyrics:", error.message);
+ res.status(500).json({
+ creator: "David Cyril Tech",
+ error: "An error occurred while fetching lyrics."
+ });
+ }
+});
+
+
+// Middleware to parse query parameters
+
+app.use(express.urlencoded({ extended: true }));
+
+// GPT-4o Mini AI Endpoint
+app.get("/ai/gpt4omini", async (req, res) => {
+ const { text } = req.query;
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://api.aboud-coding.store/api/ai/gpt-4o-mini-v2?prompt=${encodeURIComponent(text)}&userid=${generateRandomUserId()}`
+ );
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: response.data.gpt
+ });
+ } catch (error) {
+ console.error("Error processing GPT-4o Mini request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request."
+ });
+ }
+});
+
+
+// **GPT-4 Endpoint**
+app.get("/ai/gpt44", async (req, res) => {
+ try {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide text for GPT-4 response.",
+ });
+ }
+
+ // Generate a random user ID for each request
+ const userId = uuidv4();
+ const apiUrl = `https://bk9.fun/ai/GPT-4?q=${encodeURIComponent(text)}&userId=${encodeURIComponent(userId)}`;
+
+ // Fetch GPT-4 response
+ const response = await axios.get(apiUrl);
+ const jsonData = response.data;
+
+ if (jsonData.status && jsonData.BK9) {
+ return res.json({
+ creator: "David Cyril",
+ success: true,
+ message: jsonData.BK9,
+ });
+ } else {
+ return res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch response from GPT-4 API.",
+ });
+ }
+ } catch (error) {
+ console.error("GPT-4 API Error:", error.message);
+ return res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while fetching GPT-4 response.",
+ });
+ }
+});
+
+
+
+
+// GPT-4o Mini AI Endpoint
+app.get("ai/gpt3", async (req, res) => {
+ const { text } = req.query;
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://api.aboud-coding.store/api/ai/gpt-4o-mini-v2?prompt=${encodeURIComponent(text)}&userid=${generateRandomUserId()}`
+ );
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: response.data.gpt
+ });
+ } catch (error) {
+ console.error("Error processing your request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request."
+ });
+ }
+});
+
+
+
+// Meta AI Endpoint
+app.get("/ai/metaai", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+Meta+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Meta AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+// Llama3 AI Endpoint
+app.get("/ai/llama3", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+the+Latest+Llama3+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ message: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Llama3 AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+// Llama3 AI Endpoint
+app.get("/ai/uncensor", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+Uncensored+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing your request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+app.get("/ai/uncensor", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+Uncensored+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing your request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+app.get("/deepseek-llm-67b-chat", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+deepseek-llm-67b-chat+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+app.get("/deepseek-v3", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+deepseek-v3+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+app.get("/ai/deepseek-r1", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+deepseek-r1+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+// Movie Search Endpoint
+app.get("/movies/search", async (req, res) => {
+ const { query } = req.query;
+
+ if (!query) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Please provide a movie query."
+ });
+ }
+
+ try {
+ // Fetch movie search results from the new API
+ const response = await axios.get(`https://www.dark-yasiya-api.site/movie/sinhalasub/search?text=${encodeURIComponent(query)}`);
+ const results = response.data.result.movies;
+
+ if (!results || results.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ status: false,
+ message: `โ No results found for: ${query}`
+ });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ results
+ });
+ } catch (error) {
+ console.error("Movie Search Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Failed to fetch movie search results."
+ });
+ }
+});
+
+
+
+
+
+
+
+
+// **Movie Download Endpoint**
+app.get("/movies/download", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Please provide a movie URL."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api-site-2.vercel.app/api/sinhalasub/movie?url=${encodeURIComponent(url)}`);
+ const movieDetails = response.data.result;
+ const downloadLinks = movieDetails.dl_links || [];
+
+ if (!downloadLinks.length) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ No PixelDrain links found for this movie."
+ });
+ }
+
+ // Convert PixelDrain links into direct download links
+ const directLinks = downloadLinks.map((link) => ({
+ quality: link.quality,
+ size: link.size,
+ direct_download: `https://pixeldrain.com/api/file/${link.link.split("/").pop()}?download`
+ }));
+
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ movie: {
+ title: movieDetails.title,
+ thumbnail: movieDetails.thumbnail,
+ download_links: directLinks
+ }
+ });
+ } catch (error) {
+ console.error("Movie Download Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Failed to fetch movie download links."
+ });
+ }
+});
+
+
+
+
+
+
+
+app.get("/remini", async (req, res) => {
+ const { url } = req.query;
+
+ // Check if the `url` parameter is provided
+ if (!url) {
+ return res.status(400).json({
+ status: false,
+ creator: "David Cyril",
+ error: "Need image link!"
+ });
+ }
+
+ try {
+ // Call the BK9 API with the provided image URL
+ const apiUrl = `https://bk9.fun/tools/enhance?url=${encodeURIComponent(url)}`;
+ const response = await axios.get(apiUrl, { responseType: "arraybuffer" });
+
+ // Set the content-type header to match the image type and send the enhanced image
+ res.set("Content-Type", "image/jpeg");
+ res.send(response.data);
+ } catch (error) {
+ console.error("Error enhancing image:", error.message);
+ res.status(500).json({
+ status: false,
+ creator: "David Cyril",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+function generateRandomUserId() {
+ return Math.floor(Math.random() * 1000000000).toString();
+}
+
+
+
+
+// Alexa AI Endpoint
+app.get("/ai/qwen2Coder", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+Queen2Coder+Ai+&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing qwen2Coder Ai request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+
+
+app.get("/tools/qrcode", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text or URL to generate a QR code.",
+ });
+ }
+
+ try {
+ // Generate QR code as a buffer
+ const qrBuffer = await QRCode.toBuffer(text, { type: "image/png" });
+
+ // Set response headers to return an image
+ res.setHeader("Content-Type", "image/png");
+ res.send(qrBuffer);
+ } catch (error) {
+ console.error("QR Code Generation Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to generate QR code. Please try again later.",
+ });
+ }
+});
+
+
+
+// Mistral AI Endpoint
+app.get("/ai/mixtral", async (req, res) => {
+ const { text } = req.query;
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://api.aboud-coding.store/api/ai/mistralai?prompt=${encodeURIComponent(text)}&userid=${generateRandomUserId()}`
+ );
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: response.data.mistralai
+ });
+ } catch (error) {
+ console.error("Error processing Mistral request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request."
+ });
+ }
+});
+
+
+app.use(express.urlencoded({ extended: true }));
+
+
+
+
+
+// Alexa AI Endpoint
+
+
+
+// Alexa AI Endpoint
+app.get("/ai/qwen2Coder", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+Queen2Coder+Ai+&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing qwen2Coder Ai request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+
+
+// **Video Search API**
+app.get("/search/xnxx", async (req, res) => {
+ const { query } = req.query;
+
+ if (!query) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Please provide a search query."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.agatz.xyz/api/xnxx?message=${encodeURIComponent(query)}`);
+ const results = response.data?.data?.result || [];
+
+ if (!results.length) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ status: false,
+ message: `โ No results found for: ${query}`
+ });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ results: results
+ });
+ } catch (error) {
+ console.error("Video Search Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Failed to fetch video search results."
+ });
+ }
+});
+
+
+
+
+// **Video Download API**
+app.get("/download/xnxx", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Please provide a video URL."
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.agatz.xyz/api/xnxxdown?url=${encodeURIComponent(url)}`);
+ const videoData = response.data?.data;
+
+ if (!videoData || !videoData.files) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ No downloadable video found."
+ });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ result: {
+ title: videoData.title,
+ duration: videoData.duration,
+ info: videoData.info,
+ thumbnail: videoData.image,
+ download: {
+ high_quality: videoData.files.high,
+ low_quality: videoData.files.low
+ }
+ }
+ });
+ } catch (error) {
+ console.error("Xnxx Downloader Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ status: false,
+ message: "โ Failed to process Xnxx Downloader."
+ });j
+ }
+});
+
+
+
+
+
+/**
+ * Helper function to process API requests
+ * @param {string} model - The model name (e.g., "gpt4_o_mini")
+ * @param {string} text - The user query
+ * @param {object} res - Express response object
+ */
+const processGPTRequest = async (model, text, res) => {
+ try {
+ // External API call
+ const response = await axios.get("https://bk9.fun/ai/BK9", {
+ params: {
+ BK9: "you are chatgpt4 ai", // Context prompt
+ q: text, // User query
+ model: model, // Model type
+ },
+ });
+
+ const externalData = response.data;
+
+ // Check if the external API returned a valid response
+ if (externalData.status === true) {
+ return res.json({
+ creator: "David Cyril",
+ success: true,
+ response: externalData.BK9,
+ });
+ }
+
+ // Handle invalid responses from the external API
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch a valid response.",
+ });
+ } catch (error) {
+ console.error(`Error processing GPT-4 request:`, error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An unexpected error occurred. Please try again later.",
+ });
+ }
+};
+
+
+
+
+app.get('/xvideo', async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a video URL using the `url` parameter"
+ });
+ }
+
+ try {
+ // Fetch data from the external API
+ const response = await axios.get(`https://api.agatz.xyz/api/xvideodown?url=${encodeURIComponent(url)}`);
+ const data = response.data;
+
+ if (data.status !== 200 || !data.data) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch video details or video not found."
+ });
+ }
+
+ // Construct response
+ const videoData = {
+ creator: "David Cyril",
+ success: true,
+ title: data.data.title,
+ thumbnail: data.data.thumb,
+ download_url: data.data.url
+ };
+
+ res.status(200).json(videoData);
+ } catch (error) {
+ console.error("Error fetching video data:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while processing your request. Please try again later."
+ });
+ }
+});
+
+
+
+
+
+
+
+app.get("/ai/claude", async (req, res) => {
+ const { text } = req.query;
+
+ // Validate the input
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query using the `text` parameter.",
+ });
+ }
+
+ try {
+ // Make a request to the external API
+ const response = await axios.get("https://itzpire.com/ai/claude", {
+ params: { text },
+ });
+
+ const externalData = response.data;
+
+ // Validate the external API response
+ if (externalData.status === "success") {
+ return res.json({
+ creator: "David Cyril",
+ success: true,
+ response: externalData.result,
+ });
+ }
+
+ // If the external API fails
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch a valid response from the Claude",
+ });
+ } catch (error) {
+ console.error("Error processing Claude AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An unexpected error occurred. Please try again later.",
+ });
+ }
+});
+
+
+
+app.get("/random/bored", async (req, res) => {
+ try {
+ const { data } = await axios.get("https://api.paxsenix.biz.id/tools/bored");
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ activity: data.activity,
+ availability: data.availability,
+ type: data.type,
+ participants: data.participants,
+ price: data.price,
+ accessibility: data.accessibility,
+ duration: data.duration,
+ kidFriendly: data.kidFriendly,
+ link: data.link,
+ key: data.key
+ });
+ } catch (error) {
+ console.error("Error fetching bored activity:", error.message);
+ res.status(500).json({ creator: "David Cyril", success: false, message: "Internal server error" });
+ }
+});
+
+app.get("/random/quotes", async (req, res) => {
+ try {
+ const { data } = await axios.get("https://zenquotes.io/api/random");
+
+ if (!data || data.length === 0) {
+ return res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No quotes found."
+ });
+ }
+
+ const quoteData = data[0]; // Extracting the first quote
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: {
+ quote: quoteData.q,
+ author: quoteData.a
+ }
+ });
+ } catch (error) {
+ console.error("Error fetching quote:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Internal server error"
+ });
+ }
+});
+
+
+
+
+
+
+
+// ๐ Calculator API
+app.get("/tools/calculate", (req, res) => {
+ const { expr } = req.query;
+ if (!expr) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a valid math expression."
+ });
+ }
+
+ try {
+ let val = expr
+ .replace(/[^0-9\-\/+*รรทฯEe()piPI]/g, "")
+ .replace(/ร/g, "*")
+ .replace(/รท/g, "/")
+ .replace(/ฯ|pi/gi, "Math.PI")
+ .replace(/e/gi, "Math.E");
+
+ let result = new Function(`return ${val}`)();
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ expression: expr,
+ result: result
+ });
+ } catch (e) {
+ res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Invalid math expression."
+ });
+ }
+});
+
+// ๐ List Supported Currencies
+app.get("/tools/currencies", async (req, res) => {
+ try {
+ const response = await axios.get("https://api.exchangerate-api.com/v4/latest/USD");
+ const currencies = Object.keys(response.data.rates);
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ currencies
+ });
+ } catch (error) {
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch currency list."
+ });
+ }
+});
+
+// ๐ Currency Converter API
+app.get("/tools/convert", async (req, res) => {
+ const { amount, from, to } = req.query;
+
+ if (!amount || !from || !to) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Usage: /tools/convert?amount=100&from=USD&to=EUR"
+ });
+ }
+
+ try {
+ const response = await axios.get(`https://api.exchangerate-api.com/v4/latest/${from.toUpperCase()}`);
+ const rate = response.data.rates[to.toUpperCase()];
+
+ if (!rate) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Invalid currency code."
+ });
+ }
+
+ const convertedAmount = (parseFloat(amount) * rate).toFixed(2);
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: `${amount} ${from.toUpperCase()} = ${convertedAmount} ${to.toUpperCase()}`
+ });
+ } catch (error) {
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to fetch exchange rate."
+ });
+ }
+});
+
+
+
+
+
+
+app.get("/ai/pixtral", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+pixtral+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+app.get("/ai/gemma", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+gemma+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+app.get("/ai/qvq", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+qvq+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+app.get("/ai/claudeSonnet", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+claudeSonnet+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+app.get("/ai/deepseek-v3", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+deepseek-v3+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+app.get("/ai/deepseek-r1", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a text query."
+ });
+ }
+
+ try {
+ const response = await axios.get(
+ `https://bk9.fun/ai/BK9?BK9=you+are+deepseek-r1+Ai&q=${encodeURIComponent(text)}&model=gpt4_o_mini`
+ );
+ const { BK9 } = response.data;
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ response: BK9
+ });
+ } catch (error) {
+ console.error("Error processing Lori AI request:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request. Please try again later."
+ });
+ }
+});
+
+
+
+
+
+const TEMP_FOLDER = "temp"; // Folder to store temporary PDFs
+
+
+
+// PDF Downloader API
+app.get("/tools/pdf", async (req, res) => {
+ const { text } = req.query;
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide a search term."
+ });
+ }
+
+ try {
+ // Step 1: Download PDF from the main API
+ const pdfUrl = `https://bk9.fun/tools/pdf?q=${encodeURIComponent(text)}`;
+ const pdfResponse = await axios.get(pdfUrl, { responseType: "arraybuffer" });
+
+ // Step 2: Generate a unique filename
+ const fileName = `${uuidv4()}.pdf`;
+ const filePath = path.join(TEMP_FOLDER, fileName);
+
+ // Step 3: Save the PDF locally
+ fs.writeFileSync(filePath, pdfResponse.data);
+
+ // Step 4: Schedule file deletion after 5 minutes
+ setTimeout(() => {
+ if (fs.existsSync(filePath)) {
+ fs.unlinkSync(filePath);
+ console.log(`Deleted expired file: ${fileName}`);
+ }
+ }, 5 * 60 * 1000); // 5 minutes
+
+ // Step 5: Return JSON response with download link
+ res.json({
+ creator: "David Cyril",
+ status: 200,
+ success: true,
+ download: `https://apis.davidcyriltech.my.id/tmp/${fileName}`
+ });
+
+ } catch (error) {
+ console.error("Error downloading PDF:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to process your request."
+ });
+ }
+});
+
+// Serve static files from the tmp folder
+app.use("/temp", express.static(TEMP_FOLDER));
+
+
+
+app.get("/download/apk", async (req, res) => {
+ const { text } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide an APK name to search."
+ });
+ }
+
+ try {
+ // Step 1: Search for APK
+ const searchResponse = await axios.get(`https://bk9.fun/search/apk?q=${encodeURIComponent(text)}`);
+ const searchData = searchResponse.data;
+
+ if (!searchData.BK9 || searchData.BK9.length === 0) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "No APK found for your search."
+ });
+ }
+
+ const apkId = searchData.BK9[0].id; // Get the first APK result
+
+ // Step 2: Download APK
+ const downloadResponse = await axios.get(`https://bk9.fun/download/apk?id=${apkId}`);
+ const apkData = downloadResponse.data.BK9;
+
+ if (!apkData || !apkData.dllink) {
+ return res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to retrieve APK download link."
+ });
+ }
+
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ apk_name: apkData.name,
+ version: apkData.version,
+ size: apkData.size,
+ thumbnail: apkData.icon,
+ download_link: apkData.dllink
+ });
+
+ } catch (error) {
+ console.error("Error fetching APK:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Internal server error while fetching APK."
+ });
+ }
+});
+
+
+app.get("/ai/simi", async (req, res) => {
+ const query = req.query.query;
+ const lang = req.query.lang || "en";
+
+ if (!query) {
+ return res.status(400).json({ creator: "David Cyril", success: false, message: "Query parameter is required" });
+ }
+
+ try {
+ const { data } = await axios.get(`https://api.vreden.web.id/api/simi?query=${encodeURIComponent(query)}&lang=${lang}`);
+ res.json({
+ creator: "David Cyril",
+ success: true,
+ result: data.result
+ });
+ } catch (error) {
+ console.error("Error fetching Simi response:", error.message);
+ res.status(500).json({ creator: "David Cyril", success: false, message: "Internal server error" });
+ }
+});
+
+app.get("/random/waifu", async (req, res) => {
+ try {
+ const { data } = await axios.get("https://api.vreden.web.id/api/waifu", { responseType: "arraybuffer" });
+ res.set("Content-Type", "image/jpeg"); // Assuming the image is in JPEG format
+ res.send(data);
+ } catch (error) {
+ console.error("Error fetching waifu image:", error.message);
+ res.status(500).json({ creator: "David Cyril", success: false, message: "Internal server error" });
+ }
+});
+
+app.get("/hentai", async (req, res) => {
+ try {
+ // Fetch data from the external API
+ const response = await axios.get("https://api.agatz.xyz/api/hentaivid");
+ const data = response.data;
+
+ if (!data || !data.data || data.data.length === 0) {
+ return res.status(404).json({ error: "No videos found." });
+ }
+
+ // Pick a random video from the list
+ const randomVideo = data.data[Math.floor(Math.random() * data.data.length)];
+
+ // Return the random video details
+ res.json({
+ status: 200,
+ success: true,
+ creator: "David Cyril",
+ video: {
+ title: randomVideo.title,
+ category: randomVideo.category,
+ share_count: randomVideo.share_count,
+ views_count: randomVideo.views_count,
+ type: randomVideo.type,
+ video_1: randomVideo.video_1,
+ video_2: randomVideo.video_2,
+ link: randomVideo.link
+ }
+ });
+ } catch (error) {
+ console.error("Error fetching data:", error.message);
+ res.status(500).json({ error: "Failed to fetch data. Please try again later." });
+ }
+});
+
+
+// MP3 Download Route
+app.get('/youtube/mp3', async (req, res) => {
+ const { url } = req.query; // Get the video URL from the query parameter
+
+ if (!url) {
+ return res.status(400).json({
+ creator: 'David Cyril Tech',
+ status: 400,
+ success: false,
+ error: 'Please provide a URL in the query parameter.'
+ });
+ }
+
+ try {
+ const result = await ddownr.download(url, 'mp3');
+ res.json({
+ creator: 'David Cyril Tech',
+ status: 200,
+ success: true,
+ result: result // Include the download result
+ });
+ } catch (error) {
+ res.status(500).json({
+ creator: 'David Cyril Tech',
+ status: 500,
+ success: false,
+ error: error.message // Include the error message
+ });
+ }
+});
+
+
+
+
+
+
+const TTS_VOICES = [
+ { id: 1, name: "English (US) - Aria", code: "en-US-AriaNeural" },
+ { id: 2, name: "English (US) - Guy", code: "en-US-GuyNeural" },
+ { id: 3, name: "English (UK) - Libby", code: "en-GB-LibbyNeural" },
+ { id: 4, name: "French - Eloise", code: "fr-FR-EloiseNeural" },
+ { id: 5, name: "German - Klaus", code: "de-DE-KlausNeural" },
+ { id: 6, name: "Spanish - Dario", code: "es-ES-DarioNeural" },
+ { id: 7, name: "Japanese - Nanami", code: "ja-JP-NanamiNeural" },
+ { id: 8, name: "Chinese - Xiaoxiao", code: "zh-CN-XiaoxiaoNeural" }
+];
+
+// **Endpoint to list available voices**
+app.get("/tts/voices", (req, res) => {
+ res.json({
+ creator: "David Cyril",
+ status: true,
+ voices: TTS_VOICES
+ });
+});
+
+// **Endpoint to generate TTS audio**
+app.get("/tts", async (req, res) => {
+ const { text, voiceId } = req.query;
+
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide text for speech synthesis."
+ });
+ }
+
+ const voice = TTS_VOICES.find(v => v.id == voiceId);
+ if (!voice) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Invalid voice ID. Use /tts/voices to get available voices."
+ });
+ }
+
+ try {
+ const formData = new FormData();
+ formData.append("locale", voice.code.split("-").slice(0, 2).join("-"));
+ formData.append("content", `${text}`);
+ formData.append("ip", "46.161.194.33");
+
+ const response = await axios.post("https://app.micmonster.com/restapi/create", formData, {
+ headers: formData.getHeaders()
+ });
+
+ const audioBuffer = Buffer.from(response.data.split(',')[1], "base64");
+
+ res.set({
+ "Content-Type": "audio/mpeg",
+ "Content-Disposition": "inline; filename=tts.mp3"
+ });
+ res.send(audioBuffer);
+ } catch (error) {
+ console.error("TTS Error:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Failed to generate TTS. Please try again."
+ });
+ }
+});
+
+
+
+// TikTok Downloader Route
+app.get('/download/tiktok', async (req, res) => {
+ const { url } = req.query;
+ if (!url) {
+ return res.status(400).json({
+ creator: 'David Cyril Tech',
+ status: 400,
+ success: false,
+ error: 'Missing URL parameter',
+ });
+ }
+ try {
+ const result = await tiktokdl(url);
+ res.json({
+ creator: 'David Cyril Tech',
+ status: 200,
+ success: true,
+ result,
+ });
+ } catch (error) {
+ console.error('Error fetching TikTok data:', error);
+ res.status(500).json({
+ creator: 'David Cyril Tech',
+ status: 500,
+ success: false,
+ error: 'Internal Server Error',
+ });
+ }
+});
+
+// TikTok Downloader Route
+app.get('/ai/chatbot', async (req, res) => {
+ const { query } = req.query;
+ if (!query) {
+ return res.status(400).json({
+ creator: 'David Cyril Tech',
+ status: 400,
+ success: false,
+ error: 'Missing QUERY parameter',
+ });
+ }
+ try {
+ const result = await chatbot.send(query);
+ res.json({
+ creator: 'David Cyril Tech',
+ status: 200,
+ success: true,
+ result,
+ });
+ } catch (error) {
+ console.error('Error fetching chatbot data:', error);
+ res.status(500).json({
+ creator: 'David Cyril Tech',
+ status: 500,
+ success: false,
+ error: 'Internal Server Error',
+ });
+ }
+});
+
+app.get('/lyrics/search', async (req, res) => {
+ const { song } = req.query;
+ if (!song) {
+ return res.status(400).json({
+ creator: 'David Cyril Tech',
+ status: 400,
+ success: false,
+ error: 'Missing song parameter',
+ });
+ }
+ try {
+ const results = await lyrics.search(song);
+ if (results.length === 0) {
+ return res.status(404).json({
+ creator: 'David Cyril Tech',
+ status: 404,
+ success: false,
+ error: 'No lyrics found for the requested song',
+ });
+ }
+ res.json({
+ creator: 'David Cyril Tech',
+ status: 200,
+ success: true,
+ results,
+ });
+ } catch (error) {
+ console.error('Error searching for lyrics:', error);
+ res.status(500).json({
+ creator: 'David Cyril Tech',
+ status: 500,
+ success: false,
+ error: 'Internal Server Error',
+ });
+ }
+});
+
+app.get('/lyrics/details', async (req, res) => {
+ const { url } = req.query;
+ if (!url) {
+ return res.status(400).json({
+ creator: 'David Cyril Tech',
+ status: 400,
+ success: false,
+ error: 'Missing URL parameter',
+ });
+ }
+ try {
+ const result = await Lyrics.getLyrics(url);
+ res.json({
+ creator: 'David Cyril Tech',
+ status: 200,
+ success: true,
+ result,
+ });
+ } catch (error) {
+ console.error('Error fetching lyrics details:', error);
+ res.status(500).json({
+ creator: 'David Cyril Tech',
+ status: 500,
+ success: false,
+ error: 'Internal Server Error',
+ });
+ }
+});
+
+// Lyrics API (Same old endpoint)
+app.get("/lyrics2", async (req, res) => {
+ const { t: title, a: artist } = req.query;
+
+ if (!title || !artist) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ error: "Please provide both the title (`t`) and artist (`a`) of the song."
+ });
+ }
+
+ try {
+ // Using the new API but keeping old response format
+ const apiUrl = `https://archive-ui.tanakadomp.biz.id/search/lirik?q=${encodeURIComponent(title)}%20by%20${encodeURIComponent(artist)}`;
+ const response = await axios.get(apiUrl);
+
+ if (response.data?.result?.lyrics) {
+ res.status(200).json({
+ creator: "David Cyril",
+ title: response.data.result.title || title,
+ artist: artist,
+ lyrics: response.data.result.lyrics
+ });
+ } else {
+ res.status(404).json({
+ creator: "David Cyril",
+ error: "Lyrics not found in the database."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching lyrics:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ error: "An error occurred while fetching lyrics."
+ });
+ }
+});
+
+
+
+
+// Ephoto API Endpoint Mapping
+const ephotoEndpoints = {
+ glitchtext: 'https://en.ephoto360.com/create-digital-glitch-text-effects-online-767.html',
+ writetext: 'https://en.ephoto360.com/write-text-on-wet-glass-online-589.html',
+ advancedglow: 'https://en.ephoto360.com/advanced-glow-effects-74.html',
+ typographytext: 'https://en.ephoto360.com/create-typography-text-effect-on-pavement-online-774.html',
+ pixelglitch: 'https://en.ephoto360.com/create-pixel-glitch-text-effect-online-769.html',
+ neonglitch: 'https://en.ephoto360.com/create-impressive-neon-glitch-text-effects-online-768.html',
+ flagtext: 'https://en.ephoto360.com/nigeria-3d-flag-text-effect-online-free-753.html',
+ flag3dtext: 'https://en.ephoto360.com/free-online-american-flag-3d-text-effect-generator-725.html',
+ deletingtext: 'https://en.ephoto360.com/create-eraser-deleting-text-effect-online-717.html',
+ blackpinkstyle: 'https://en.ephoto360.com/online-blackpink-style-logo-maker-effect-711.html',
+ glowingtext: 'https://en.ephoto360.com/create-glowing-text-effects-online-706.html',
+ underwatertext: 'https://en.ephoto360.com/3d-underwater-text-effect-online-682.html',
+ logomaker: 'https://en.ephoto360.com/free-bear-logo-maker-online-673.html',
+ cartoonstyle: 'https://en.ephoto360.com/create-a-cartoon-style-graffiti-text-effect-online-668.html',
+ papercutstyle: 'https://en.ephoto360.com/multicolor-3d-paper-cut-style-text-effect-658.html',
+ watercolortext: 'https://en.ephoto360.com/create-a-watercolor-text-effect-online-655.html',
+ effectclouds: 'https://en.ephoto360.com/write-text-effect-clouds-in-the-sky-online-619.html',
+ blackpinklogo: 'https://en.ephoto360.com/create-blackpink-logo-online-free-607.html',
+ gradienttext: 'https://en.ephoto360.com/create-3d-gradient-text-effect-online-600.html',
+ summerbeach: 'https://en.ephoto360.com/write-in-sand-summer-beach-online-free-595.html',
+ luxurygold: 'https://en.ephoto360.com/create-a-luxury-gold-text-effect-online-594.html',
+ multicoloredneon: 'https://en.ephoto360.com/create-multicolored-neon-light-signatures-591.html',
+ sandsummer: 'https://en.ephoto360.com/write-in-sand-summer-beach-online-576.html',
+ galaxywallpaper: 'https://en.ephoto360.com/create-galaxy-wallpaper-mobile-online-528.html',
+ '1917style': 'https://en.ephoto360.com/1917-style-text-effect-523.html',
+ makingneon: 'https://en.ephoto360.com/making-neon-light-text-effect-with-galaxy-style-521.html',
+ royaltext: 'https://en.ephoto360.com/royal-text-effect-online-free-471.html',
+ freecreate: 'https://en.ephoto360.com/free-create-a-3d-hologram-text-effect-441.html',
+ galaxystyle: 'https://en.ephoto360.com/create-galaxy-style-free-name-logo-438.html',
+ lighteffects: 'https://en.ephoto360.com/create-light-effects-green-neon-online-429.html',
+};
+
+// Function to interact with the Ephoto360 API
+async function ephoto(link, text) {
+ try {
+ const response = await axios.post(link, { text }); // Adjust as per API requirements
+ return response.data.imageUrl; // Replace with the actual key for the generated image URL
+ } catch (error) {
+ console.error(`Error fetching Ephoto360: ${error.message}`);
+ throw new Error("Failed to generate image. Please try again later.");
+ }
+}
+
+app.get('/api/ephoto/:effect', async (req, res) => {
+ const { effect } = req.params; // Extract effect from URL
+ const { text } = req.query; // Extract text from query parameters
+
+ // Validate the text parameter
+ if (!text) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Please provide the text using the `text` query parameter.",
+ });
+ }
+
+ // Validate the effect parameter
+ const link = ephotoEndpoints[effect];
+ if (!link) {
+ return res.status(404).json({
+ creator: "David Cyril",
+ success: false,
+ message: "Invalid effect name. Please check the available effects.",
+ });
+ }
+
+ try {
+ // Fetch the generated image URL
+ const imageUrl = await ephoto(link, text);
+
+ // Redirect to the generated image URL
+ res.redirect(imageUrl);
+ } catch (error) {
+ res.status(500).json({
+ creator: "David Cyril",
+ success: false,
+ message: "An error occurred while generating the image.",
+ });
+ }
+});
+
+
+app.get("/imdb", async (req, res) => {
+ const { query } = req.query;
+
+ // Validate the query parameter
+ if (!query) {
+ return res.status(400).json({
+ status: false,
+ creator: "David Cyril",
+ error: "Please provide a `query` parameter."
+ });
+ }
+
+ try {
+ // API call to Popcat's IMDb Search
+ const apiUrl = `https://api.popcat.xyz/imdb?q=${encodeURIComponent(query)}`;
+ const response = await axios.get(apiUrl);
+
+ // Process the response
+ if (response.data) {
+ return res.status(200).json({
+ status: true,
+ creator: "David Cyril",
+ query,
+ movie: {
+ title: response.data.title,
+ year: response.data.year,
+ rated: response.data.rated,
+ released: response.data.released,
+ runtime: response.data.runtime,
+ genres: response.data.genres,
+ director: response.data.director,
+ writer: response.data.writer,
+ actors: response.data.actors,
+ plot: response.data.plot,
+ languages: response.data.languages,
+ country: response.data.country,
+ awards: response.data.awards,
+ poster: response.data.poster,
+ ratings: response.data.ratings,
+ metascore: response.data.metascore,
+ imdbRating: response.data.rating,
+ votes: response.data.votes,
+ boxoffice: response.data.boxoffice,
+ imdbUrl: response.data.imdburl
+ }
+ });
+ } else {
+ return res.status(404).json({
+ status: false,
+ creator: "David Cyril",
+ error: "No movie found for the provided query."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching movie details:", error.message);
+ return res.status(500).json({
+ status: false,
+ creator: "David Cyril",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+app.get("/mediafire", async (req, res) => {
+ const { url } = req.query;
+
+ if (!url) {
+ return res.status(400).json({
+ creator: "David Cyril",
+ error: "Please provide the MediaFire URL in the `url` query parameter."
+ });
+ }
+
+ try {
+ const apiUrl = `https://api.agatz.xyz/api/mediafire?url=${encodeURIComponent(url)}`;
+ const response = await axios.get(apiUrl);
+
+ if (response.data.status === 200 && response.data.data.length > 0) {
+ const fileData = response.data.data[0];
+
+ res.status(200).json({
+ creator: "David Cyril",
+ fileName: fileData.nama,
+ mimeType: fileData.mime,
+ size: fileData.size,
+ downloadLink: fileData.link,
+ });
+ } else {
+ res.status(404).json({
+ creator: "David Cyril",
+ error: "File information could not be retrieved."
+ });
+ }
+ } catch (error) {
+ console.error("Error fetching MediaFire file:", error.message);
+ res.status(500).json({
+ creator: "David Cyril",
+ error: "An error occurred while processing your request."
+ });
+ }
+});
+
+
+
+
+
+
+
+
+
+app.get('/record/convert', async (req, res) => {
+ const { url } = req.query; // Extract URL from query parameter
+
+ if (!url) {
+ return res.status(400).json({
+ creator: 'David Cyril Tech',
+ status: 400,
+ success: false,
+ error: 'Please provide a URL in the query parameter.'
+ });
+ }
+
+ try {
+ const result = await svweb.recording(url, 1, '--convert');
+ res.json({
+ creator: 'David Cyril Tech',
+ status: 200,
+ success: true,
+ filePath: result.filePath,
+ message: 'Video has been successfully saved.',
+ });
+ } catch (error) {
+ res.status(500).json({
+ creator: 'David Cyril Tech',
+ status: 500,
+ success: false,
+ error: error.message
+ });
+ }
+});
+
+// Route for Video Recording (Raw Data)
+app.get('/record/raw', async (req, res) => {
+ const { url } = req.query; // Extract URL from query parameter
+
+ if (!url) {
+ return res.status(400).json({
+ creator: 'David Cyril Tech',
+ status: 400,
+ success: false,
+ error: 'Please provide a URL in the query parameter.'
+ });
+ }
+
+ try {
+ const result = await svweb.recording(url, 1, '--unconvert');
+ res.json({
+ creator: 'David Cyril Tech',
+ status: 200,
+ success: true,
+ type: result.type,
+ data: result.data,
+ });
+ } catch (error) {
+ res.status(500).json({
+ creator: 'David Cyril Tech',
+ status: 500,
+ success: false,
+ error: error.message
+ });
+ }
+});
+
+
+
+
+
+
+const CREATOR = "David Cyril";
+
+// Spotify API Credentials
+const clientId = "0770a58ad3aa482c80602ee21a41df9d";
+const clientSecret = "f8b11f7a139f4abb89743c36ebebea4e";
+
+// Function to Get Spotify Access Token
+async function getAccessToken() {
+ try {
+ const authString = Buffer.from(`${clientId}:${clientSecret}`).toString("base64");
+ const tokenEndpoint = "https://accounts.spotify.com/api/token";
+
+ const response = await axios.post(
+ tokenEndpoint,
+ "grant_type=client_credentials",
+ {
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ "Authorization": `Basic ${authString}`,
+ },
+ }
+ );
+
+ return response.data.access_token;
+ } catch (error) {
+ console.error("Spotify Auth Error:", error.message);
+ return null;
+ }
+}
+
+// Function to Search for a Song on Spotify
+async function searchSong(songName, accessToken) {
+ try {
+ const searchEndpoint = `https://api.spotify.com/v1/search?q=${encodeURIComponent(songName)}&type=track`;
+
+ const response = await axios.get(searchEndpoint, {
+ headers: {
+ "Authorization": `Bearer ${accessToken}`,
+ },
+ });
+
+ return response.data.tracks.items.map(track => ({
+ title: track.name,
+ duration: `${(track.duration_ms / 60000).toFixed(2)} min`, // Convert ms to minutes
+ popularity: `${track.popularity}%`,
+ preview: track.preview_url || "No preview available",
+ artist: track.artists.map(artist => artist.name).join(", "),
+ album: track.album.name,
+ url: track.external_urls.spotify,
+ }));
+ } catch (error) {
+ console.error("Spotify Search Error:", error.message);
+ return null;
+ }
+}
+
+// API Endpoint to Search for a Song
+app.get("/spotify-v2", async (req, res) => {
+ const { query } = req.query;
+
+ if (!query) {
+ return res.status(400).json({
+ creator: CREATOR,
+ status: 400,
+ success: false,
+ message: "Please provide a song name using the `query` parameter.",
+ });
+ }
+
+ const accessToken = await getAccessToken();
+ if (!accessToken) {
+ return res.status(500).json({
+ creator: CREATOR,
+ status: 500,
+ success: false,
+ message: "Failed to get Spotify access token.",
+ });
+ }
+
+ const results = await searchSong(query, accessToken);
+ if (!results || results.length === 0) {
+ return res.status(404).json({
+ creator: CREATOR,
+ status: 404,
+ success: false,
+ message: "No songs found for the given query.",
+ });
+ }
+
+ res.json({
+ creator: CREATOR,
+ status: 200,
+ success: true,
+ result: results,
+ });
+});
+
+
+
+
+
+
+
+
+const session_hash = Math.random().toString(36).slice(2);
+const base = "https://rooc-flux-fast.hf.space";
+
+const endpoints = {
+ join: `${base}/gradio_api/queue/join`,
+ dataStream: `${base}/gradio_api/queue/data?session_hash=${session_hash}`
+};
+
+async function fluxImage(prompt) {
+ try {
+ let payload = {
+ data: [prompt],
+ event_data: null,
+ fn_index: 0,
+ session_hash,
+ trigger_id: 10
+ };
+
+ let { data } = await axios.post(endpoints.join, payload);
+ let event_id = data.event_id;
+ let imageUrl = null;
+
+ const responseStream = await axios.get(endpoints.dataStream, { responseType: "stream" });
+
+ for await (const chunk of responseStream.data) {
+ let lines = chunk
+ .toString()
+ .split("\n")
+ .filter(line => line.startsWith("data: "));
+
+ for (let line of lines) {
+ let parsed = JSON.parse(line.replace("data: ", ""));
+ if (parsed.msg === "process_completed" && parsed.event_id === event_id) {
+ imageUrl = parsed.output.data[0].url;
+ break;
+ }
+ }
+ if (imageUrl) break;
+ }
+
+ return imageUrl;
+ } catch (error) {
+ console.error("Error in Flux API:", error.message);
+ return null;
+ }
+}
+
+// API Endpoint to Serve the Image Directly
+app.get("/fluxpro", async (req, res) => {
+ const { prompt } = req.query;
+
+ if (!prompt) {
+ return res.status(400).json({
+ creator: "David Cyril Tech",
+ status: 400,
+ success: false,
+ message: "Please provide a `prompt` parameter."
+ });
+ }
+
+ const imageUrl = await fluxImage(prompt);
+
+ if (imageUrl) {
+ try {
+ const imageResponse = await axios.get(imageUrl, { responseType: "arraybuffer" });
+
+ // Send image data
+ res.setHeader("Content-Type", "image/webp");
+ res.send(imageResponse.data);
+ } catch (error) {
+ console.error("Error fetching image:", error.message);
+ res.status(500).json({
+ creator: "David Cyril Tech",
+ status: 500,
+ success: false,
+ message: "Failed to fetch the generated image."
+ });
+ }
+ } else {
+ res.status(500).json({
+ creator: "David Cyril Tech",
+ status: 500,
+ success: false,
+ message: "Failed to generate image. Please try again."
+ });
+ }
+});
+
+
+
+
+
+
+async function generateBook(size, text) {
+ try {
+ let payload = {
+ color: "#000000",
+ font: "arch",
+ size: size,
+ text: text
+ };
+
+ let { data } = await axios.post("https://lemon-write.vercel.app/api/generate-book", payload, {
+ responseType: "arraybuffer"
+ });
+
+ return data; // Return image buffer
+ } catch (error) {
+ console.error("Error in Book Generator API:", error.message);
+ return null;
+ }
+}
+
+// API Endpoint to Serve the Generated Book Image
+app.get("/generate/book", async (req, res) => {
+ const { text, size } = req.query;
+
+ if (!text || !size) {
+ return res.status(400).json({
+ creator: "David Cyril Tech",
+ status: 400,
+ success: false,
+ message: "Please provide both `text` and `size` parameters."
+ });
+ }
+
+ const imageBuffer = await generateBook(Number(size), text);
+
+ if (imageBuffer) {
+ res.setHeader("Content-Type", "image/jpeg");
+ res.send(imageBuffer);
+ } else {
+ res.status(500).json({
+ creator: "David Cyril Tech",
+ status: 500,
+ success: false,
+ message: "Failed to generate book image."
+ });
+ }
+});
+
+
+
+
+
+
+// 404 Handler
+app.use((req, res) => {
+ res.status(404).sendFile(path.join(__dirname, 'public/404/index.html'));
+});
+
+// Start Server
+app.listen(port, () => {
+ console.log(`Server running on port ${port}`);
+});