From a2df9a69dcc14cb70118cda2ded499055e7ee358 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 21 Aug 2022 17:31:56 +0200 Subject: m. update --- api/app-images.php | 43 ++++++++++++++++++++++++++++++++++++++++++ api/cloudburst-banners.php | 17 +++++++++++++++++ api/cloudburst-data.php | 44 +++++++++++++++++++++++++++++++++++++++++++ api/cloudburst.php | 6 ++++++ api/data.php | 12 ++++++++++++ api/me-picture.php | 23 ++++++++++++++++++++++ api/me.php | 13 +++++++++++++ api/pluralkit-integration.php | 36 +++++++++++++++++++++++++++++++++++ api/raindrops-banners.php | 17 +++++++++++++++++ api/raindrops-data.php | 44 +++++++++++++++++++++++++++++++++++++++++++ api/raindrops.php | 6 ++++++ api/save.php | 4 ++-- api/session.php | 6 ++++++ api/test.php | 4 ++++ api/token.php | 7 +++++++ api/video.php | 39 ++++++++++++++++++++++++++++++++++++++ 16 files changed, 319 insertions(+), 2 deletions(-) create mode 100644 api/app-images.php create mode 100644 api/cloudburst-banners.php create mode 100644 api/cloudburst-data.php create mode 100644 api/cloudburst.php create mode 100644 api/data.php create mode 100644 api/me-picture.php create mode 100644 api/me.php create mode 100644 api/pluralkit-integration.php create mode 100644 api/raindrops-banners.php create mode 100644 api/raindrops-data.php create mode 100644 api/raindrops.php create mode 100644 api/session.php create mode 100644 api/test.php create mode 100644 api/token.php create mode 100644 api/video.php (limited to 'api') diff --git a/api/app-images.php b/api/app-images.php new file mode 100644 index 0000000..edab3c9 --- /dev/null +++ b/api/app-images.php @@ -0,0 +1,43 @@ + [], + "profile" => [], + "misc" => [] +]; + +$data["misc"]["systems"] = [ + "cloudburst.png" => "data:image/png;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/cloudburst.png")), + "raindrops.png" => "data:image/png;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/raindrops.png")) +]; + +foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads"), function ($i) { return str_starts_with($i, "ss-") && str_ends_with($i, ".png"); }) as $file) { + $data["misc"]["systems"][$file] = "data:image/png;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/" . $file)); +} + +$data["misc"]["species"] = []; + +foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/assets/species"), function ($i) { return !str_starts_with($i, "."); }) as $file) { + $name = substr($file, 0, strlen($file) - 4); + $data["misc"]["species"][$name] = "data:" . mime_content_type($_SERVER['DOCUMENT_ROOT'] . "/assets/species/" . $file) . ";base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/species/" . $file)); +} + +foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/images"), function ($i) { return !str_starts_with($i, "."); }) as $file) { + $name = explode(".", $file)[0]; + $parts = explode("-", $name); + $type = mime_content_type($_SERVER['DOCUMENT_ROOT'] . "/includes/data/images/" . $file); + $category = match ($parts[0]) { + "pt" => "ponytown", + "pf" => "profile" + }; + + if (!isset($data[$category][$parts[1]])) $data[$category][$parts[1]] = []; + $data[$category][$parts[1]][$parts[2]] = "data:" . $type . ";base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/images/" . $file)); +} + +header("Content-Type: application/json"); +die(json_encode($data, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/api/cloudburst-banners.php b/api/cloudburst-banners.php new file mode 100644 index 0000000..6e1d654 --- /dev/null +++ b/api/cloudburst-banners.php @@ -0,0 +1,17 @@ + null, + "content" => null + ]; + if ($parts[1] === "metadata") { + $data["members"][$parts[0]][$parts[1]] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file), true)); + } else { + $data["members"][$parts[0]][$parts[1]] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file), true); + } + } else { + $data[$name] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file), true); + } + } else { + if (strlen($parts[0]) === 5) { + if (!isset($data["members"][$parts[0]])) $data["members"][$parts[0]] = [ + "metadata" => null, + "content" => null + ]; + $data["members"][$parts[0]][$parts[1]] = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file); + } else { + $data[$name] = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file); + } + } + } +} + +header("Content-Type: application/json"); +die(json_encode($data, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/api/cloudburst.php b/api/cloudburst.php new file mode 100644 index 0000000..3002e00 --- /dev/null +++ b/api/cloudburst.php @@ -0,0 +1,6 @@ + null, + "content" => null + ]; + if ($parts[1] === "metadata") { + $data["members"][$parts[0]][$parts[1]] = parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file), true)); + } else { + $data["members"][$parts[0]][$parts[1]] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file), true); + } + } else { + $data[$name] = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file), true); + } + } else { + if (strlen($parts[0]) === 5) { + if (!isset($data["members"][$parts[0]])) $data["members"][$parts[0]] = [ + "metadata" => null, + "content" => null + ]; + $data["members"][$parts[0]][$parts[1]] = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file); + } else { + $data[$name] = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $file); + } + } + } +} + +header("Content-Type: application/json"); +die(json_encode($data, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/api/raindrops.php b/api/raindrops.php new file mode 100644 index 0000000..9f07aff --- /dev/null +++ b/api/raindrops.php @@ -0,0 +1,6 @@ + $i["height"], + "id" => $i['format_id'] + ]; + }, $data["formats"]), function ($i) { + return !is_null($i["quality"]); + })); + $hd = array_values(array_filter($qualities, function ($i) { + return $i["quality"] >= 720; + })); + $selected = count($hd) > 0 ? $hd[0] : $qualities[count($qualities) - 1]; + $stream = array_values(array_filter($data["formats"], function ($i) use ($selected) { + return $i["height"] === $selected["quality"] && $i["acodec"] !== null && $i["acodec"] !== "none"; + }))[0]; + + echo(json_encode([ + "title" => $data["fulltitle"], + "author" => $data["channel"], + "count" => [ + "channel" => $data["channel_follower_count"], + "likes" => $data["like_count"], + "views" => $data["view_count"] + ], + "duration" => $data["duration"], + "stream" => $selected, + "url" => $stream["url"], + "duration_pretty" => $stream["duration_string"], + "poster" => $data["thumbnail"], + ], JSON_PRETTY_PRINT)); +} \ No newline at end of file -- cgit