Open M336G opened 2 months ago
<?php
$music = 'https://www.youtube.com/watch?v=bv0_KXEwNUw';
$data = array(
"url" => $music,
"aFormat" => "mp3",
"isAudioOnly" => true
);
$postdata = json_encode($data);
$ch = curl_init("https://api.cobalt.tools/api/json");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
$result = json_decode(curl_exec($ch));
curl_close($ch);
if($result->status != "stream") exit("-1"); // Change to Dashboard error.
$musicFile = $result->url;
echo $musicFile;
Here's cobalt API already. Download link is stored at $musicFile. It's possible.
Are these links permanent?
Are these links permanent?
Nah it uses the old API, so it'll probably be deprecated in the future
Nah it uses the old API, so it'll probably be deprecated in the future
I mean output result links
<?php
// assuming $music has been handled correctly
$music = 'https://www.youtube.com/watch?v=bv0_KXEwNUw';
$data = array(
"url" => $music,
"aFormat" => "mp3",
"isAudioOnly" => true
);
$postdata = json_encode($data);
$ch = curl_init("https://api.cobalt.tools/api/json");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
$result = json_decode(curl_exec($ch));
curl_close($ch);
if($result->status != "stream") exit("Fuck");
// change lol.mp3 with a random int.mp3 (see /dashboard/songs/index.php)
file_put_contents("lol.mp3", file_get_contents($result->url));
current POC, needs to be implemented correctly
Add a tab to upload songs with a YouTube URL via the Cobalt API (only if the song file reupload option is enabled, of course).