![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/ |
<?php
require_once 'config/database.php';
echo "<h1>🚀 Update All Tracks with Lyrics</h1>";
echo "<p><strong>This script will re-sync ALL your existing tracks to get the missing lyrics data from API.Box.</strong></p>";
try {
$pdo = getDBConnection();
// Get all tracks that need lyrics
$tracks_query = "SELECT id, task_id, title, lyrics FROM music_tracks WHERE (lyrics IS NULL OR lyrics = '') AND task_id IS NOT NULL ORDER BY created_at DESC";
$tracks_stmt = $pdo->query($tracks_query);
$tracks = $tracks_stmt->fetchAll(PDO::FETCH_ASSOC);
if (empty($tracks)) {
echo "<p style='color: green; font-weight: bold;'>✅ All tracks already have lyrics!</p>";
exit;
}
echo "<p><strong>Found " . count($tracks) . " tracks without lyrics that need updating.</strong></p>";
// Show tracks that will be updated
echo "<h2>📋 Tracks to Update:</h2>";
echo "<table style='width: 100%; border-collapse: collapse; margin: 15px 0;'>";
echo "<tr style='background: #667eea; color: white;'>";
echo "<th style='padding: 10px; border: 1px solid #ccc;'>Track ID</th>";
echo "<th style='padding: 10px; border: 1px solid #ccc;'>Task ID</th>";
echo "<th style='padding: 10px; border: 1px solid #ccc;'>Title</th>";
echo "<th style='padding: 10px; border: 1px solid #ccc;'>Current Status</th>";
echo "</tr>";
foreach ($tracks as $track) {
echo "<tr style='background: #ffe8e8;'>";
echo "<td style='padding: 10px; border: 1px solid #ccc;'>{$track['id']}</td>";
echo "<td style='padding: 10px; border: 1px solid #ccc;'>{$track['task_id']}</td>";
echo "<td style='padding: 10px; border: 1px solid #ccc;'>" . htmlspecialchars($track['title']) . "</td>";
echo "<td style='padding: 10px; border: 1px solid #ccc;'>❌ No lyrics</td>";
echo "</tr>";
}
echo "</table>";
echo "<h2>🔄 Update Options:</h2>";
echo "<div style='background: #f0f8ff; border: 1px solid #ccc; padding: 20px; border-radius: 10px; margin: 20px 0;'>";
echo "<h3>Option 1: Run Full Sync (Recommended)</h3>";
echo "<p>This will update ALL tracks with complete data including lyrics, metadata, and enhanced features.</p>";
echo "<p><strong>Command:</strong> <code>php sync_all_tracks_full.php</code></p>";
echo "<p><strong>Time:</strong> Depends on number of tracks (could take 10-30 minutes)</p>";
echo "<p><strong>What it does:</strong> Fetches fresh data from API.Box for every track</p>";
echo "</div>";
echo "<div style='background: #fff8f0; border: 1px solid #ccc; padding: 20px; border-radius: 10px; margin: 20px 0;'>";
echo "<h3>Option 2: Run Enhanced Sync</h3>";
echo "<p>This uses the enhanced sync script with better error handling and more data fields.</p>";
echo "<p><strong>Command:</strong> <code>php enhanced_api_box_sync.php</code></p>";
echo "<p><strong>Time:</strong> Similar to full sync</p>";
echo "<p><strong>What it does:</strong> Enhanced version with better data extraction</p>";
echo "</div>";
echo "<div style='background: #f8fff0; border: 1px solid #ccc; padding: 20px; border-radius: 10px; margin: 20px 0;'>";
echo "<h3>Option 3: Test with Single Track First</h3>";
echo "<p>Test the lyrics extraction with just one track before running the full sync.</p>";
echo "<p><strong>Test Script:</strong> <code>php test_lyrics_structure.php</code></p>";
echo "<p><strong>What it does:</strong> Shows exactly what data structure API.Box is sending</p>";
echo "</div>";
echo "<h2>🎯 Recommended Action:</h2>";
echo "<ol>";
echo "<li><strong>First:</strong> Run <code>php test_lyrics_structure.php</code> to verify the data structure</li>";
echo "<li><strong>Then:</strong> Run <code>php sync_all_tracks_full.php</code> to update all tracks</li>";
echo "<li><strong>Finally:</strong> Check <code>php check_existing_lyrics.php</code> to see the results</li>";
echo "</ol>";
echo "<h2>⚠️ Important Notes:</h2>";
echo "<ul>";
echo "<li><strong>API Rate Limits:</strong> API.Box may have rate limits, so the sync might take time</li>";
echo "<li><strong>Existing Data:</strong> This will update existing tracks, not create duplicates</li>";
echo "<li><strong>Backup:</strong> Your existing data is safe - this only adds missing information</li>";
echo "<li><strong>Callback Fixed:</strong> New tracks will automatically get lyrics from now on</li>";
echo "</ul>";
echo "<h2>🚀 Ready to Update?</h2>";
echo "<p>Choose your option and run the command. The sync will:</p>";
echo "<ul>";
echo "<li>✅ Fetch lyrics for all tracks that have them available</li>";
echo "<li>✅ Update metadata and enhanced features</li>";
echo "<li>✅ Make lyrics appear on your track pages</li>";
echo "<li>✅ Fix the disconnect between API.Box and your database</li>";
echo "</ul>";
} catch (Exception $e) {
echo "<p style='color: red;'>❌ Error: " . htmlspecialchars($e->getMessage()) . "</p>";
}
?>