From 41c51b8bdb9c8e9fa4a7d56f260d594739d4107e Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Mon, 30 Oct 2023 23:08:45 +0100 Subject: Updated 35 files and added 28 files (automated) --- api/hasStella.php | 11 +++++++++++ api/lyrics.php | 22 ++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 api/hasStella.php (limited to 'api') diff --git a/api/hasStella.php b/api/hasStella.php new file mode 100644 index 0000000..7e335b7 --- /dev/null +++ b/api/hasStella.php @@ -0,0 +1,11 @@ + true, "payload" => $data["lines"] ], JSON_PRETTY_PRINT)); +} elseif (isset($data) && str_starts_with($data["syncType"], "UNSYNCED")) { + die(json_encode([ + "synced" => false, + "payload" => implode("\n", array_map(function ($i) { + return $i["words"]; + }, $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([ +$id = array_values(array_filter(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"]; +])), true)["response"]["hits"], function ($i) { + return !str_contains(strtolower($i["result"]["artist_names"]), "genius"); +}))[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); + } elseif (str_ends_with($i, "2Embed")) { + return substr($i, 0, -6); + } elseif (str_ends_with($i, "Embed")) { + return substr($i, 0, -5); } else { return $i; } @@ -48,7 +62,7 @@ $data = array_slice(array_map(function ($i) { if (count($data) > 0) { die(json_encode([ "synced" => false, - "payload" => implode("\n", $data) + "payload" => str_replace("You might also like", "", str_replace("You might also like\n", "", trim(implode("\n", $data)))) ], JSON_PRETTY_PRINT)); } -- cgit