summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-27 13:32:25 +0200
committerRaindropsSys <contact@minteck.org>2023-04-27 13:32:25 +0200
commit59b56c2283c12c8a82144a836faee4f12b15e5c1 (patch)
tree1d6930b8799f37b2023231d0db253b8a980807d8 /pages
parent633c92eae865e957121e08de634aeee11a8b3992 (diff)
downloadpluralconnect-59b56c2283c12c8a82144a836faee4f12b15e5c1.tar.gz
pluralconnect-59b56c2283c12c8a82144a836faee4f12b15e5c1.tar.bz2
pluralconnect-59b56c2283c12c8a82144a836faee4f12b15e5c1.zip
Updated 5 files and deleted 2 files (automated)
Diffstat (limited to 'pages')
-rw-r--r--pages/api/plex-thumb.php11
-rw-r--r--pages/api/plex.php88
-rw-r--r--pages/jobs.inc11
3 files changed, 11 insertions, 99 deletions
diff --git a/pages/api/plex-thumb.php b/pages/api/plex-thumb.php
deleted file mode 100644
index 4009871..0000000
--- a/pages/api/plex-thumb.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-$app = $GLOBALS["ColdHazeApp"];
-
-if (isset($_GET["library"]) && isset($_GET["id"]) && is_numeric($_GET["library"]) && is_numeric($_GET["id"])) {
- header("Content-Type: image/jpg");
- die(file_get_contents("https://plex.equestria.dev/library/metadata/" . $_GET["library"] . "/thumb/" . $_GET["id"] . "?X-Plex-Token=" . $app["plex"]));
-} else {
- header("HTTP/1.1 400 Invalid request");
- die("Invalid request");
-} \ No newline at end of file
diff --git a/pages/api/plex.php b/pages/api/plex.php
deleted file mode 100644
index 00164c7..0000000
--- a/pages/api/plex.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/random.inc";
-$app = $GLOBALS["ColdHazeApp"];
-
-function formatTitle($metadata) {
- if ($metadata['grandparentTitle']) {
- return $metadata['grandparentTitle'];
- } else {
- $ret = $metadata['title'];
- if ($metadata['year']) {
- $ret .= " (" . $metadata['year'] . ")";
- }
- return $ret;
- }
-}
-
-function formatSubtitle($metadata) {
- $ret = '';
-
- if ($metadata['grandparentTitle']) {
- if ($metadata['type'] === 'track') {
- $ret = $metadata['parentTitle'];
- } else if ($metadata['index'] && $metadata['parentIndex']) {
- $ret = "S" . $metadata['parentIndex'] . " E" . $metadata['index'];
- } else if ($metadata['originallyAvailableAt']) {
- $ret = $metadata['originallyAvailableAt'];
- }
-
- if ($metadata['title']) {
- $ret .= ' - ' . $metadata['title'];
- }
- } else if ($metadata['type'] === 'movie') {
- $ret = $metadata['tagline'];
- }
-
- return $ret;
-}
-
-$payload = json_decode($_POST["payload"], true);
-
-if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/cache")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/assets/cache");
-$id = random(32);
-
-if ($payload["Metadata"]["type"] === "track") {
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/cache/" . $id . ".jpg", file_get_contents("https://plex.equestria.dev" . $payload["Metadata"]["thumb"] . "?X-Plex-Token=" . $app["plex"]));
-} else {
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/cache/" . $id . ".jpg", file_get_contents("https://plex.equestria.dev" . $payload["Metadata"]["grandparentThumb"] . "?X-Plex-Token=" . $app["plex"]));
-}
-
-if ($payload["event"] === "playback.started" || $payload["event"] === "media.play") {
- $hookObject = json_encode([
- "username" => "Plex",
- "avatar_url" => "https://support.plex.tv/wp-content/themes/plex/assets/img/favicons/plex-192.png",
- "embeds" => [
- [
- "title" => formatTitle($payload["Metadata"]),
- "type" => "rich",
- "description" => formatSubtitle($payload["Metadata"]),
- "color" => hexdec( "2b2d31" ),
- "thumbnail" => [
- "url" => "https://ponies.equestria.horse/assets/cache/" . $id . ".jpg"
- ],
- "footer" => [
- "text" => $payload["Account"]["title"] . " ยท Playing from " . $payload["Player"]["title"],
- "icon_url" => $payload["Account"]["thumb"]
- ]
- ]
- ]
-
- ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
-}
-
-if (isset($hookObject)) {
- $ch = curl_init();
-
- curl_setopt_array( $ch, [
- CURLOPT_URL => $app["webhook"]["plex"],
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $hookObject,
- CURLOPT_HTTPHEADER => [
- "Content-Type: application/json"
- ]
- ]);
-
- $response = curl_exec( $ch );
- curl_close( $ch );
-} \ No newline at end of file
diff --git a/pages/jobs.inc b/pages/jobs.inc
index 6723175..c00e35c 100644
--- a/pages/jobs.inc
+++ b/pages/jobs.inc
@@ -4,6 +4,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; gl
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/util/functions.inc';
$history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history.json"), true);
+$running = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/running.json"), true);
if (isset($_GET["enqueue"]) && isset($history[(int)$_GET["enqueue"]])) {
createJob(explode("(", $history[(int)$_GET["enqueue"]]["name"])[0], $history[(int)$_GET["enqueue"]]["options"]);
@@ -73,6 +74,16 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
<?php endif; ?>
<div class="list-group">
+ <?php foreach (array_reverse(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs"), function ($i) {
+ return !str_starts_with($i, ".");
+ })) as $index => $file): $item = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/jobs/" . $file), true); ?>
+ <div class="list-group-item disabled" style="list-style: none; display: grid; grid-template-columns: 3fr repeat(2, 1fr);">
+ <div><?= $item["name"] ?>(<?php foreach ($item["options"] as $name => $value): echo($name . "=" . json_encode($value)); endforeach; ?>)</div>
+ <div><?= timeAgo($item["date"]) ?></div>
+ <div><?php if (isset($running) && $file === $running): ?><span class="text-info">Running</span><?php else: ?><span class="text-warning">Pending</span><?php endif; ?></div>
+ </div>
+ <?php endforeach; ?>
+
<?php foreach ($history as $index => $item): ?>
<details class="list-group-item">
<summary style="list-style: none; display: grid; grid-template-columns: 3fr repeat(2, 1fr);">