![]() 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/utils/ |
<?php
require_once 'config/database.php';
$pdo = getDBConnection();
echo "<h2>Fixing Failed Tracks</h2>";
// Get the "fun fun" track specifically
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE title LIKE '%fun fun%' AND status = 'failed'");
$stmt->execute();
$fun_fun_track = $stmt->fetch();
if ($fun_fun_track) {
echo "<h3>Found 'fun fun' track (ID: " . $fun_fun_track['id'] . ")</h3>";
echo "<p>Current status: " . $fun_fun_track['status'] . "</p>";
echo "<p>Task ID: " . $fun_fun_track['task_id'] . "</p>";
// This track has a temp_ task ID, so we need to regenerate it
$api_url = 'https://api.api.box/api/v1/generate';
$api_key = '63edba40620216c5aa2c04240ac41dbd';
$api_data = [
'prompt' => $fun_fun_track['prompt'] ?: 'fun fun',
'model' => 'V3_5',
'style' => 'Pop',
'title' => $fun_fun_track['title'],
'customMode' => false,
'instrumental' => false,
'duration' => 30,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
echo "<p>Regenerating track with API.Box...</p>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($api_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$api_result = json_decode($response, true);
if ($http_code === 200 && isset($api_result['code']) && $api_result['code'] === 200) {
$new_task_id = $api_result['data']['taskId'];
// Update the track with new task ID and status
$stmt = $pdo->prepare("UPDATE music_tracks SET task_id = ?, status = 'processing' WHERE id = ?");
$stmt->execute([$new_task_id, $fun_fun_track['id']]);
echo "<p style='color: green;'>✅ 'fun fun' track regenerated!</p>";
echo "<p>New Task ID: $new_task_id</p>";
echo "<p>Status updated to: processing</p>";
} else {
echo "<p style='color: red;'>❌ Failed to regenerate track</p>";
echo "<p>Response: " . htmlspecialchars($response) . "</p>";
}
} else {
echo "<p>No 'fun fun' track found in failed status</p>";
}
// Now fix all other failed tracks with temp_ task IDs
echo "<h3>Fixing Other Failed Tracks</h3>";
$stmt = $pdo->query("
SELECT * FROM music_tracks
WHERE status = 'failed' AND task_id LIKE 'temp_%'
ORDER BY created_at DESC
");
$temp_tracks = $stmt->fetchAll();
foreach ($temp_tracks as $track) {
echo "<p>Fixing track: " . htmlspecialchars($track['title']) . " (ID: " . $track['id'] . ")</p>";
$api_data = [
'prompt' => $track['prompt'] ?: 'Music generation',
'model' => 'V3_5',
'style' => 'Pop',
'title' => $track['title'],
'customMode' => false,
'instrumental' => false,
'duration' => 30,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($api_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$api_result = json_decode($response, true);
if ($http_code === 200 && isset($api_result['code']) && $api_result['code'] === 200) {
$new_task_id = $api_result['data']['taskId'];
// Update the track
$stmt = $pdo->prepare("UPDATE music_tracks SET task_id = ?, status = 'processing' WHERE id = ?");
$stmt->execute([$new_task_id, $track['id']]);
echo "<p style='color: green;'>✅ Track " . $track['id'] . " regenerated with Task ID: $new_task_id</p>";
} else {
echo "<p style='color: red;'>❌ Failed to regenerate track " . $track['id'] . "</p>";
}
}
echo "<h3>✅ Fix Complete!</h3>";
echo "<p>All failed tracks with temp_ task IDs have been regenerated with API.Box.</p>";
echo "<p>They should now show as 'Processing' and will be updated to 'Complete' when the music is ready.</p>";
?>