summaryrefslogtreecommitdiff
path: root/api/lyrics.php
diff options
context:
space:
mode:
Diffstat (limited to 'api/lyrics.php')
-rw-r--r--api/lyrics.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/api/lyrics.php b/api/lyrics.php
index d72a17c..74503dc 100644
--- a/api/lyrics.php
+++ b/api/lyrics.php
@@ -2,6 +2,7 @@
header("X-Frame-Options: SAMEORIGIN");
header("Content-Type: application/json");
+//header("Content-Type: text/plain");
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $songs;
$token = json_decode(file_exists("/opt/spotify/token.json") ? file_get_contents("/opt/spotify/token.json") : file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/includes/app.json"), true);
@@ -34,6 +35,22 @@ if (isset($data) && str_ends_with($data["syncType"], "_SYNCED")) {
], JSON_PRETTY_PRINT));
}
+$probe = [];
+exec("ffprobe -v quiet -print_format json -show_format $_SERVER[DOCUMENT_ROOT]/assets/content/$_GET[id].flac", $probe);
+$metadata = json_decode(implode("\n", $probe), true);
+
+if (isset($metadata["format"]["tags"]["UNSYNCEDLYRICS"])) {
+ die(json_encode([
+ "synced" => false,
+ "payload" => trim($metadata["format"]["tags"]["UNSYNCEDLYRICS"])
+ ], JSON_PRETTY_PRINT));
+} elseif (isset($metadata["format"]["tags"]["unsyncedlyrics"])) {
+ die(json_encode([
+ "synced" => false,
+ "payload" => trim($metadata["format"]["tags"]["unsyncedlyrics"])
+ ], JSON_PRETTY_PRINT));
+}
+
$genius = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["genius"];
$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([