diff --git a/Podfetch/Podfetch.php b/Podfetch/Podfetch.php index a52757d062..459bd928bd 100644 --- a/Podfetch/Podfetch.php +++ b/Podfetch/Podfetch.php @@ -1,7 +1,69 @@ url("/api/v1/info")); + echo $test->status; + } + + public function livestats() + { + $status = "inactive"; + + $res1 = parent::execute($this->url("/api/v1/podcasts")); + $podcasts = json_decode($res1->getBody()); + + $res2 = parent::execute($this->url("/api/v1/sys/info")); + $sysinfo = json_decode($res2->getBody()); + + $data = []; + if ($podcasts && is_array($podcasts)) { + $data["podcast_count"] = count($podcasts); + $status = "active"; + } + if ($sysinfo && isset($sysinfo->podcast_directory)) { + $data["disk_used"] = self::fmt($sysinfo->podcast_directory); + $free = array_sum(array_column($sysinfo->disks ?? [], 'available_space')); + $data["disk_free"] = self::fmt($free); + $status = "active"; + } + + return parent::getLiveStats($status, $data); + } + + private static function fmt($bytes) + { + if ($bytes >= 1099511627776) { + return round($bytes / 1099511627776, 1) . 'T'; + } + if ($bytes >= 1073741824) { + return round($bytes / 1073741824, 1) . 'G'; + } + return round($bytes / 1048576, 1) . 'M'; + } + + public function url($endpoint) + { + $api_url = parent::normaliseurl($this->config->url); + $username = $this->config->username; + $password = $this->config->password; + $rebuild_url = str_replace( + "http://", + "http://" . $username . ":" . $password . "@", + $api_url + ); + $rebuild_url = str_replace( + "https://", + "https://" . $username . ":" . $password . "@", + $rebuild_url + ); + $rebuild_url = rtrim($rebuild_url, "/"); + return $rebuild_url . $endpoint; + } } diff --git a/Podfetch/app.json b/Podfetch/app.json index 91f2514a0a..f6a1bbd9ee 100644 --- a/Podfetch/app.json +++ b/Podfetch/app.json @@ -1,10 +1,10 @@ { - "appid": "433dc2c56e482aa6d8bc5cfae5ac5e4ec3d0f752", - "name": "Podfetch", - "website": "https://podfetch.com/", - "license": "Apache License 2.0", - "description": "Podfetch es un gestor de podcasts autohospedado. Es una aplicación web que permite descargar podcasts y escucharlos en línea. Está escrita en Rust y utiliza React para el frontend. Además, incluye integración con GPodder, por lo que puedes seguir usando tu aplicación de podcasts actual.", - "enhanced": false, - "tile_background": "light", - "icon": "podfetch.png" + "appid": "433dc2c56e482aa6d8bc5cfae5ac5e4ec3d0f752", + "name": "PodFetch", + "website": "https://github.com/SamTV12345/PodFetch", + "license": "GPL-3.0", + "description": "Self-hosted podcast manager with GPodder sync, Audiobookshelf API, transcripts, and Chromecast support.", + "enhanced": true, + "tile_background": "light", + "icon": "PodFetch.png" } diff --git a/Podfetch/config.blade.php b/Podfetch/config.blade.php new file mode 100644 index 0000000000..26b4af285c --- /dev/null +++ b/Podfetch/config.blade.php @@ -0,0 +1,18 @@ +