From ffe4625436fa7ba95847bd1879b83a918897b98a Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 16 Feb 2026 20:28:55 +0000 Subject: [PATCH] Auto commit: 2026-02-16T20:28:55.842Z --- api/top-songs.php | 27 ++++++++++++++++++++++++ index.php | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 api/top-songs.php diff --git a/api/top-songs.php b/api/top-songs.php new file mode 100644 index 0000000..7448d0a --- /dev/null +++ b/api/top-songs.php @@ -0,0 +1,27 @@ +prepare(" + SELECT song_title, likes_count + FROM song_likes + WHERE last_liked_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) + ORDER BY likes_count DESC + LIMIT 5 + "); + $stmt->execute(); + $songs = $stmt->fetchAll(PDO::FETCH_ASSOC); + + echo json_encode([ + 'success' => true, + 'data' => $songs + ]); +} catch (Exception $e) { + echo json_encode([ + 'success' => false, + 'error' => $e->getMessage() + ]); +} diff --git a/index.php b/index.php index 9a3cc47..13cf13b 100644 --- a/index.php +++ b/index.php @@ -771,6 +771,15 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489";
+
+ + TOP CANCIONES DE LA SEMANA + +
+
Cargando ranking...
+
+
+
@@ -1445,11 +1454,17 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; item.style.fontSize = '0.75rem'; item.style.border = '1px solid rgba(255,255,255,0.05)'; + const likesCount = track.likes || '0'; + item.innerHTML = `
${track.title}
+
+ + ${likesCount} +
`; list.appendChild(item); }); @@ -1458,6 +1473,34 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; // Initial render renderRecentTracks(); + async function fetchTopSongs() { + try { + const response = await fetch('api/top-songs.php'); + const result = await response.json(); + if (result.success && result.data) { + const list = document.getElementById('top-songs-list'); + if (result.data.length === 0) { + list.innerHTML = '
Aún no hay votos esta semana.
'; + return; + } + list.innerHTML = result.data.map((song, index) => ` +
+
+ #${index + 1} + ${song.song_title} +
+
+ + ${song.likes_count} +
+
+ `).join(''); + } + } catch (error) { + console.error('Error fetching top songs:', error); + } + } + // Fetch Now Playing Metadata from RadioKing async function updateMetadata() { try { @@ -1478,7 +1521,8 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; if (trackTitle.textContent !== "Cargando stream..." && trackTitle.textContent !== "Lili Records Radio - En Vivo") { const prevTrack = { title: trackTitle.textContent, - cover: trackCover.src + cover: trackCover.src, + likes: document.getElementById('like-count').innerText || '0' }; // Avoid duplicates if (recentTracks.length === 0 || recentTracks[0].title !== prevTrack.title) { @@ -1558,7 +1602,11 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; // Update every 30 seconds updateMetadata(); - setInterval(updateMetadata, 30000); + fetchTopSongs(); + setInterval(() => { + updateMetadata(); + fetchTopSongs(); + }, 30000); // Handle possible audio interruptions audio.addEventListener('error', function(e) {