[ "method" => "GET", "header" => "Authorization: Bearer " . $token["access_token"] . "\r\n" ] ])), true)["tracks"]["items"][0]["id"]; $data = json_decode(file_get_contents("http://localhost:8000/public/?trackid=" . $id), true); if (isset($data) && str_ends_with($data["syncType"], "_SYNCED")) { die(json_encode([ "synced" => true, "payload" => $data["lines"] ], JSON_PRETTY_PRINT)); } $genius = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["genius"]; $id = json_decode(file_get_contents("https://api.genius.com/search?q=" . rawurlencode($song["title"] . " " . $song["artist"]), false, stream_context_create([ "http" => [ "method" => "GET", "header" => "Authorization: Bearer " . $genius . "\r\n" ] ])), true)["response"]["hits"][0]["result"]["id"]; $data = []; exec('bash -c "cd /opt/spotify/spotify-lyrics-api; python genius.py ' . $id . '"', $data); $data = array_slice(array_map(function ($i) { if (str_ends_with($i, "1Embed")) { return substr($i, 0, -6); } else { return $i; } }, $data), 1); if (count($data) > 0) { die(json_encode([ "synced" => false, "payload" => implode("\n", $data) ], JSON_PRETTY_PRINT)); } die(json_encode([ "synced" => false, "payload" => null ], JSON_PRETTY_PRINT));