diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/lyrics.php | 14 | ||||
-rw-r--r-- | api/randomFavorites.php | 8 |
2 files changed, 19 insertions, 3 deletions
diff --git a/api/lyrics.php b/api/lyrics.php index 11910d9..d72a17c 100644 --- a/api/lyrics.php +++ b/api/lyrics.php @@ -48,9 +48,17 @@ $id = array_values(array_filter(json_decode(file_get_contents("https://api.geniu $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")) { + if (str_ends_with($i, "1Embed") + || str_ends_with($i, "2Embed") + || str_ends_with($i, "3Embed") + || str_ends_with($i, "4Embed") + || str_ends_with($i, "5Embed") + || str_ends_with($i, "6Embed") + || str_ends_with($i, "7Embed") + || str_ends_with($i, "8Embed") + || str_ends_with($i, "9Embed") + || str_ends_with($i, "0Embed") + ) { return substr($i, 0, -6); } elseif (str_ends_with($i, "Embed")) { return substr($i, 0, -5); diff --git a/api/randomFavorites.php b/api/randomFavorites.php new file mode 100644 index 0000000..8994c6f --- /dev/null +++ b/api/randomFavorites.php @@ -0,0 +1,8 @@ +<?php + +header("X-Frame-Options: SAMEORIGIN"); +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; +header("Content-Type: application/json"); +global $favorites; +shuffle($favorites); +die(json_encode($favorites));
\ No newline at end of file |