diff --git a/Tdarr/Tdarr.php b/Tdarr/Tdarr.php index e4f1788f3..f0a951acd 100644 --- a/Tdarr/Tdarr.php +++ b/Tdarr/Tdarr.php @@ -1,5 +1,86 @@ url('api/v2/status/'); + $test = parent::appTest($url); + + echo $test->status; + } + + public function livestats() + { + $status = 'inactive'; + + $reqData = array( + 'data' => array( + 'collection' => 'StatisticsJSONDB', + 'mode' => 'getById', + 'docID' => 'statistics' + ) , + ); + + $url = $this->url('api/v2/cruddb/'); + // Setup cURL + $ch = curl_init($url); + curl_setopt_array($ch, array( + CURLOPT_POST => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => array( + 'Content-Type: application/json' + ) , + CURLOPT_POSTFIELDS => json_encode($reqData) + )); + + // Send the request + $response = curl_exec($ch); + + // Check for errors + if ($response === false) + { + die(curl_error($ch)); + } + + $details = []; + // Decode the response + $details = json_decode($response, true); + + $data = []; + $data['queue'] = ''; + $data['processed'] = ''; + $data['errored'] = ''; + + if ($details) + { + $data['queue'] = $details['table1Count'] + $details['table4Count']; + $data['processed'] = $details['table2Count'] + $details['table5Count']; + $errored = $details['table3Count'] + $details['table6Count']; + if ($errored > 0) + { + $data['errored'] = $errored; + } + } + + // Close the cURL handler + curl_close($ch); + + return parent::getLiveStats($status, $data); + } + public function url($endpoint) + { + $api_url = parent::normaliseurl($this + ->config + ->url) . $endpoint; + return $api_url; + } +} -} \ No newline at end of file diff --git a/Tdarr/app.json b/Tdarr/app.json index 1e95149f6..812bb7a69 100644 --- a/Tdarr/app.json +++ b/Tdarr/app.json @@ -4,7 +4,7 @@ "website": "https://github.com/HaveAGitGat/Tdarr", "license": "GNU General Public License v3.0 only", "description": "Tdarr is a self hosted web-app for automating media library transcode/remux management and making sure your files are exactly how you need them to be in terms of codecs/streams/containers etc. Designed to work alongside Sonarr/Radarr and built with the aim of modularisation, parallelisation and scalability, each library you add has its own transcode settings, filters and schedule. Workers can be fired up and closed down as necessary, and are split into 3 types - 'general', 'transcode' and 'health check'. Worker limits can be managed by the scheduler as well as manually. For a desktop application with similar functionality please see HBBatchBeast.", - "enhanced": false, + "enhanced": true, "tile_background": "dark", "icon": "tdarr.png" } \ No newline at end of file diff --git a/Tdarr/config.blade.php b/Tdarr/config.blade.php new file mode 100644 index 000000000..53f26e13c --- /dev/null +++ b/Tdarr/config.blade.php @@ -0,0 +1,10 @@ +