const express = require('express'); const axios = require('axios'); const FormData = require('form-data'); const fs = require('fs'); const path = require('path'); const app = express(); const PORT = 7860; app.get('/addsong', async (req, res) => { const youtubeUrl = req.query.url; if (!youtubeUrl) return res.status(400).send('No URL provided.'); try { const ytdlResponse = await axios.get( `https://ccproject.serv00.net/ytdl2.php?url=${encodeURIComponent(youtubeUrl)}`, { headers: { 'User-Agent': 'Mozilla/5.1' } } ); const data = ytdlResponse.data; if (!data.download || !data.title) return res.status(400).send('Invalid response from YTDL API.'); const downloadUrl = data.download; const title = data.title; const timestamp = Date.now(); const filename = `${timestamp}.mp3`; const filePath = path.join(__dirname, filename); const fileDownload = await axios({ method: 'get', url: downloadUrl, responseType: 'stream', headers: { 'User-Agent': 'Mozilla/5.1' } }); const writer = fs.createWriteStream(filePath); fileDownload.data.pipe(writer); await new Promise((resolve, reject) => { writer.on('finish', resolve); writer.on('error', reject); }); const form = new FormData(); form.append('file', fs.createReadStream(filePath)); const uploadResponse = await axios.post( 'https://ccproject.serv00.net/cc.php', form, { headers: { ...form.getHeaders(), 'User-Agent': 'Mozilla/5.1' } } ); if (!uploadResponse.data.url) { fs.unlinkSync(filePath); return res.status(400).send('Invalid response from upload API.'); } const uploadedUrl = uploadResponse.data.url; const addSongApi = `http://gdphps.ccproject.serv00.net/dashboard/api/addSong.php?download=${encodeURIComponent(uploadedUrl)}&author=GdphMusicGD&name=${encodeURIComponent(title)}`; const finalResponse = await axios.get(addSongApi, { headers: { 'User-Agent': 'Mozilla/5.1' } }); fs.unlinkSync(filePath); res.send(finalResponse.data); } catch (error) { res.status(500).send(error.toString()); } }); app.get("/api/catbox", async (req, res) => { const url = req.query.url; if (!url) return res.status(400).json({ error: "Missing 'url' parameter" }); try { const saveDir = path.join(__dirname, "public"); if (!fs.existsSync(saveDir)) fs.mkdirSync(saveDir, { recursive: true }); const timestamp = Date.now(); const filePath = path.join(saveDir, `${timestamp}.mp3`); const response = await axios.get(url, { responseType: "arraybuffer" }); fs.writeFileSync(filePath, response.data); const form = new FormData(); form.append("reqtype", "fileupload"); form.append("userhash", ""); form.append("fileToUpload", fs.createReadStream(filePath)); const uploadResponse = await axios.post("https://catbox.moe/user/api.php", form, { headers: { ...form.getHeaders(), "User-Agent": "Mozilla/5.0", "Accept": "application/json", "Accept-Encoding": "gzip, deflate, br, zstd", "sec-ch-ua-platform": '"Android"', "cache-control": "no-cache", "sec-ch-ua": '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"', "sec-ch-ua-mobile": "?1", "x-requested-with": "XMLHttpRequest", "dnt": "1", "origin": "https://catbox.moe", "sec-fetch-site": "same-origin", "sec-fetch-mode": "cors", "sec-fetch-dest": "empty", "referer": "https://catbox.moe/", "accept-language": "en-US,en;q=0.9", "priority": "u=1, i" } }); fs.unlink(filePath, () => {}); res.json({ fileUrl: uploadResponse.data.trim() }); } catch (error) { res.status(500).json({ error: "Failed to upload file", details: error.message }); } }); const cheerio = require('cheerio'); const categoryEmojiMap = { "Night icon": "🌙", "Gear icon": "⚙️", "Egg icon": "🥚", "Cosmetics icon": "💅", "Honey icon": "🍯", "Seeds icon": "🌱" }; async function getStockItems() { const url = 'https://growagarden.gg/stocks'; try { const { data } = await axios.get(url); const $ = cheerio.load(data); const stocks = []; $('article.group.relative.rounded-lg.border-border\\/40.bg-card\\/20.p-4.transition-all.duration-300.hover\\:shadow-xl.hover\\:shadow-primary\\/10').each((i, parentElem) => { const stockCategory = $(parentElem).find('h2.text-lg.font-semibold').text().trim(); const svgAriaLabel = $(parentElem).find('svg').attr('aria-label'); const categoryEmoji = categoryEmojiMap[svgAriaLabel] || ''; const items = []; $(parentElem).find('article.group.relative.flex.items-center.gap-3.rounded-lg.border.bg-background\\/50.p-3.transition-all.duration-300.hover\\:scale-\\[1\\.02\\].hover\\:bg-background\\/80').each((j, itemElem) => { const itemName = $(itemElem).find('h3.text-sm.font-medium').text().trim(); const itemEmoji = $(itemElem).find('div.absolute.-bottom-1.-right-1.rounded-full.border.border-border\\/50.bg-background\\/80.p-0.5.text-lg.shadow-sm').text().trim(); items.push({ name: itemName, emoji: itemEmoji, id: `${stockCategory.toLowerCase().replace(/\s+/g, '-')}-${i}-${j}` }); }); stocks.push({ category: stockCategory, categoryEmoji: categoryEmoji, items: items, count: items.length }); }); return { success: true, lastUpdated: new Date().toISOString(), data: stocks.filter(stock => ["Night Stock", "Gear Stock", "Egg Stock", "Cosmetics Stock", "Honey Stock", "Seeds Stock"] .includes(stock.category) ) }; } catch (error) { console.error(`Error fetching stock data: ${error}`); return { success: false, error: error.message, message: "Failed to fetch stock data" }; } } app.get('/grow', async (req, res) => { try { const stockData = await getStockItems(); res.json(stockData); } catch (error) { console.error('Error in /grow route:', error); res.status(500).json({ success: false, error: error.message, message: "Internal server error" }); } }); const { spawn } = require("child_process"); const botFiles = [ "bot.js" ]; function startBot(file) { console.log(`Starting bot: ${file}`); const child = spawn("node", ["--trace-warnings", "--async-stack-traces", file], { cwd: __dirname, stdio: "inherit", shell: true, }); child.on("close", (codeExit) => { console.log(`Bot process (${file}) exited with code: ${codeExit}`); if (codeExit !== 0) { setTimeout(() => startBot(file), 3000); } }); child.on("error", (error) => { console.error(`An error occurred starting the bot (${file}): ${error}`); }); } botFiles.forEach(startBot); // Spotify part api nowiybru const SPOTIFY_API = { BASE: 'https://api.spotify.com/v1', AUTH: 'https://accounts.spotify.com/api/token', CLIENT_ID: 'b0cdfaef5b0b401299244ef88df29ffb', CLIENT_SECRET: '3e5949b78a214aecb2558b861911c1a9' }; const FAB_DL_API = 'https://api.fabdl.com'; let spotifyToken = null; let tokenExpiry = null; async function getSpotifyToken() { if (spotifyToken && Date.now() < tokenExpiry) { return spotifyToken; } try { const authString = Buffer.from(`${SPOTIFY_API.CLIENT_ID}:${SPOTIFY_API.CLIENT_SECRET}`).toString('base64'); const response = await axios.post(SPOTIFY_API.AUTH, 'grant_type=client_credentials', { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': `Basic ${authString}` } }); spotifyToken = response.data.access_token; tokenExpiry = Date.now() + (response.data.expires_in * 1000); return spotifyToken; } catch (error) { console.error(error); throw new Error('Failed to get Spotify token'); } } function formatDuration(ms) { const minutes = Math.floor(ms / 60000); const seconds = Math.floor((ms % 60000) / 1000); return `${minutes}:${seconds.toString().padStart(2, '0')}`; } app.get('/api/spotify', async (req, res) => { try { const { url, search } = req.query; if (url) { const token = await getSpotifyToken(); const trackId = url.split('/').pop().split('?')[0]; const trackResponse = await axios.get(`${SPOTIFY_API.BASE}/tracks/${trackId}`, { headers: { 'Authorization': `Bearer ${token}` } }); const fabResponse = await axios.get(`${FAB_DL_API}/spotify/get?url=${url}`); const downloadResponse = await axios.get( `${FAB_DL_API}/spotify/mp3-convert-task/${fabResponse.data.result.gid}/${fabResponse.data.result.id}` ); res.json({ title: trackResponse.data.name, artist: trackResponse.data.artists.map(a => a.name).join(', '), duration: formatDuration(trackResponse.data.duration_ms), cover: trackResponse.data.album.images[0]?.url, downloadUrl: `${FAB_DL_API}${downloadResponse.data.result.download_url}` }); } else if (search) { const token = await getSpotifyToken(); const searchResponse = await axios.get( `${SPOTIFY_API.BASE}/search?q=${encodeURIComponent(search)}&type=track&limit=10`, { headers: { 'Authorization': `Bearer ${token}` } } ); const tracks = searchResponse.data.tracks.items.map(track => ({ id: track.id, title: track.name, artist: track.artists.map(a => a.name).join(', '), duration: formatDuration(track.duration_ms), cover: track.album.images[0]?.url, url: track.external_urls.spotify })); res.json(tracks); } else { res.status(400).json({ error: 'Missing url or search parameter' }); } } catch (error) { console.error(error); res.status(500).json({ error: 'Internal server error' }); } }); app.listen(PORT, () => { console.log(`Server running at http://localhost:${PORT}`); });