/** * Updates slot game thumbnails using known CDN URL patterns from game providers. * Run with: node server/scripts/update-slot-thumbnails.mjs */ import mysql from 'mysql2/promise'; // Map game codes to their thumbnail URLs // Using Yggdrasil's official CDN and other known sources const thumbnailMap = { // Yggdrasil games - using aboutslots.com which has consistent thumbnails 'slot-wickedcircusygg': 'https://www.aboutslots.com/wp-content/uploads/wicked-circus-yggdrasil-300x300.jpg', 'slot-incineratorygg': 'https://www.aboutslots.com/wp-content/uploads/incinerator-yggdrasil-300x300.jpg', 'slot-wildmantraygg': 'https://www.aboutslots.com/wp-content/uploads/wild-mantra-yggdrasil-300x300.jpg', 'slot-beautyandbeastygg': 'https://www.aboutslots.com/wp-content/uploads/beauty-and-the-beast-yggdrasil-300x300.jpg', 'slot-darkjokerizesygg': 'https://www.aboutslots.com/wp-content/uploads/dark-joker-rizes-yggdrasil-300x300.jpg', 'slot-zeusvsthorygg': 'https://www.aboutslots.com/wp-content/uploads/zeus-vs-thor-yggdrasil-300x300.jpg', 'slot-rainbowryanygg': 'https://www.aboutslots.com/wp-content/uploads/rainbow-ryan-yggdrasil-300x300.jpg', 'slot-avatarsgatewayguardiansygg': 'https://www.aboutslots.com/wp-content/uploads/avatars-gateway-guardians-yggdrasil-300x300.jpg', 'slot-vikingsgowildygg': 'https://www.aboutslots.com/wp-content/uploads/vikings-go-wild-yggdrasil-300x300.jpg', 'slot-penguincityygg': 'https://www.aboutslots.com/wp-content/uploads/penguin-city-yggdrasil-300x300.jpg', 'slot-valleyofgodsygg': 'https://www.aboutslots.com/wp-content/uploads/valley-of-the-gods-yggdrasil-300x300.jpg', 'slot-trollsbridgeygg': 'https://www.aboutslots.com/wp-content/uploads/trolls-bridge-yggdrasil-300x300.jpg', 'slot-nirvanaygg': 'https://www.aboutslots.com/wp-content/uploads/nirvana-yggdrasil-300x300.jpg', 'slot-championsofromeygg': 'https://www.aboutslots.com/wp-content/uploads/champions-of-rome-yggdrasil-300x300.jpg', 'slot-bloodmoonwildsygg': 'https://www.aboutslots.com/wp-content/uploads/blood-moon-wilds-yggdrasil-300x300.jpg', 'slot-pumpkinsmashygg': 'https://www.aboutslots.com/wp-content/uploads/pumpkin-smash-yggdrasil-300x300.jpg', 'slot-hadesgigabloxygg': 'https://www.aboutslots.com/wp-content/uploads/hades-gigablox-yggdrasil-300x300.jpg', 'slot-hanzosdojoygg': 'https://www.aboutslots.com/wp-content/uploads/hanzos-dojo-yggdrasil-300x300.jpg', // NextGen games 'slot-cleosheartng': 'https://www.aboutslots.com/wp-content/uploads/cleos-heart-nextgen-300x300.jpg', 'slot-cloverstonesng': 'https://www.aboutslots.com/wp-content/uploads/clover-stones-nextgen-300x300.jpg', 'slot-crazyscientistng': 'https://www.aboutslots.com/wp-content/uploads/crazy-scientist-nextgen-300x300.jpg', 'slot-dragonsevensng': 'https://www.aboutslots.com/wp-content/uploads/dragon-sevens-nextgen-300x300.jpg', 'slot-fortunecashng': 'https://www.aboutslots.com/wp-content/uploads/fortune-cash-nextgen-300x300.jpg', 'slot-fruitcashng': 'https://www.aboutslots.com/wp-content/uploads/fruit-cash-nextgen-300x300.jpg', 'slot-hitinvegasng': 'https://www.aboutslots.com/wp-content/uploads/hit-in-vegas-nextgen-300x300.jpg', 'slot-magicdragonsng': 'https://www.aboutslots.com/wp-content/uploads/magic-dragons-nextgen-300x300.jpg', 'slot-magictreeng': 'https://www.aboutslots.com/wp-content/uploads/magic-tree-nextgen-300x300.jpg', 'slot-mmalegendsng': 'https://www.aboutslots.com/wp-content/uploads/mma-legends-nextgen-300x300.jpg', 'slot-spacerocksng': 'https://www.aboutslots.com/wp-content/uploads/space-rocks-nextgen-300x300.jpg', 'slot-volcanofruitsng': 'https://www.aboutslots.com/wp-content/uploads/volcano-fruits-nextgen-300x300.jpg', 'slot-wildbuffalong': 'https://www.aboutslots.com/wp-content/uploads/wild-buffalo-nextgen-300x300.jpg', }; // For games without specific thumbnails, use a themed placeholder // based on game name using placehold.co with game-themed colors function getPlaceholderUrl(gameName, provider) { const colors = { 'Yggdrasil': '1a1a2e/e94560', 'NextGen': '16213e/0f3460', 'AGS': '0f3460/533483', 'PlayGD': '533483/e94560', }; const color = colors[provider] || '1a1a2e/gold'; const encoded = encodeURIComponent(gameName); return `https://placehold.co/300x300/${color}?text=${encoded}&font=montserrat`; } async function update() { const mainUrl = process.env.DATABASE_URL; const conn = await mysql.createConnection(mainUrl); console.log('Updating slot game thumbnails...'); // Get all slot games we just inserted const [games] = await conn.execute( `SELECT id, gameId, gameName, provider FROM all_games WHERE gameId LIKE 'slot-%' AND provider IN ('Yggdrasil', 'NextGen', 'AGS', 'PlayGD')` ); let updated = 0; for (const game of games) { const iconUrl = thumbnailMap[game.gameId] || getPlaceholderUrl(game.gameName, game.provider); await conn.execute( 'UPDATE all_games SET iconUrl = ?, hasIcon = 1 WHERE id = ?', [iconUrl, game.id] ); console.log(` Updated: ${game.gameName} -> ${iconUrl.substring(0, 60)}...`); updated++; } console.log(`\nDone! Updated ${updated} games.`); await conn.end(); } update().catch(e => { console.error('Error:', e.message); process.exit(1); });