// Substituído pelos seus dados novos const API_URL = 'https://api.painelwb.com.br/fixtures'; const API_TOKEN = '2327aa4975db80785d0c365cdf11ffdf-asc-edge9'; let currentOffset = 0; let currentCategory = 'all'; // DATABASE DE LIGAS (Mantido o seu original) const LIGAS = { 71: { name: "Brasileirão A", channels: ["Globo", "Premiere"], cat: 'br', destaque: true }, 72: { name: "Brasileirão B", channels: ["Premiere", "SporTV"], cat: 'br', destaque: false }, 73: { name: "Copa do Brasil", channels: ["Globo", "Amazon", "SporTV"], cat: 'br', destaque: true }, 13: { name: "Libertadores", channels: ["Globo", "Disney+", "Paramount"], cat: 'br', destaque: true }, 2: { name: "Champions League", channels: ["SBT", "TNT", "Max"], cat: 'world', destaque: true }, 39: { name: "Premier League", channels: ["ESPN", "Disney+"], cat: 'world', destaque: true }, // ... adicione outras ligas conforme necessário }; function getChannelHtml(channels) { if (!channels || channels.length === 0) return 'A Confirmar'; return channels.map(ch => { let cls = 'ch-generic'; const name = ch.toLowerCase(); if (name.includes('globo')) cls = 'ch-globo'; else if (name.includes('premiere')) cls = 'ch-premiere'; else if (name.includes('disney')) cls = 'ch-disney'; else if (name.includes('max')) cls = 'ch-max'; else if (name.includes('espn')) cls = 'ch-espn'; else if (name.includes('cazé')) cls = 'ch-cazetv'; return `${ch}`; }).join(''); } function shareMatch(home, away, scoreHome, scoreAway, status, league, channels) { const text = encodeURIComponent(`⚽ *GIRO DE GOLS*\n\n🏆 ${league}\n⚔️ ${home} ${scoreHome} x ${scoreAway} ${away}\n⏰ ${status}\n📺 ${channels.join(', ')}`); window.open(`https://api.whatsapp.com/send?text=${text}`); } async function fetchData() { const resultsDiv = document.getElementById('results'); resultsDiv.innerHTML = '
'; const date = new Date(); date.setDate(date.getDate() + currentOffset); const dateStr = date.toISOString().split('T')[0]; try { // AJUSTE NA CHAMADA: Usando o novo cabeçalho de autorização const res = await fetch(`${API_URL}?date=${dateStr}`, { headers: { 'Authorization': `Bearer ${API_TOKEN}`, 'Content-Type': 'application/json' } }); const data = await res.json(); // Tentativa de mapear a resposta (ajuste conforme a estrutura real da painelwb) let matches = (data.response || data.data || []).filter(item => { const info = LIGAS[item.league.id]; if (!info) return false; return (currentCategory === 'all' || info.cat === currentCategory); }); if (matches.length === 0) { resultsDiv.innerHTML = `
Nenhum jogo das ligas favoritas para esta data.
`; return; } matches.sort((a, b) => (LIGAS[b.league.id]?.destaque ? 1 : 0) - (LIGAS[a.league.id]?.destaque ? 1 : 0)); resultsDiv.innerHTML = matches.map(item => { const info = LIGAS[item.league.id]; const status = item.fixture.status; const isLive = ['1H', '2H', 'HT', 'ET', 'P'].includes(status.short); const currentStatusTxt = isLive ? `AO VIVO ${status.elapsed}'` : (['FT', 'AET', 'PEN'].includes(status.short) ? 'ENCERRADO' : new Date(item.fixture.date).toLocaleTimeString('pt-BR', {hour:'2-digit', minute:'2-digit'})); return `
${info.destaque ? '
🔥 Jogão
' : ''}
🏆 ${info.name}
${getChannelHtml(info.channels)}
${item.teams.home.name}
${item.goals.home ?? 0} - ${item.goals.away ?? 0}
${currentStatusTxt}
${item.teams.away.name}
`; }).join(''); } catch (e) { console.error(e); resultsDiv.innerHTML = `
Erro ao conectar com a nova API. Verifique o console.
`; } } // Funções de navegação (Mantidas) function changeDate(offset) { currentOffset = offset; document.querySelectorAll('.date-nav .btn').forEach(b => b.classList.remove('active')); if(offset === -1) document.getElementById('d-prev').classList.add('active'); if(offset === 0) document.getElementById('d-today').classList.add('active'); if(offset === 1) document.getElementById('d-next').classList.add('active'); fetchData(); } function changeCategory(cat) { currentCategory = cat; document.querySelectorAll('.category-nav .btn').forEach(b => b.classList.remove('active')); document.getElementById(`c-${cat}`).classList.add('active'); fetchData(); } function filterList() { const query = document.getElementById('searchInput').value.toLowerCase(); document.querySelectorAll('.match-card').forEach(card => { card.style.display = card.innerText.toLowerCase().includes(query) ? 'block' : 'none'; }); } fetchData();