From 7ed83f6c9eb5d42a90184b8d59edb3109e8184f3 Mon Sep 17 00:00:00 2001 From: mrquatsch Date: Sat, 17 Feb 2018 08:59:06 -0600 Subject: [PATCH 1/5] config for enhanced pleypy app --- resources/views/supportedapps/plexpy.blade.app | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 resources/views/supportedapps/plexpy.blade.app diff --git a/resources/views/supportedapps/plexpy.blade.app b/resources/views/supportedapps/plexpy.blade.app new file mode 100644 index 00000000..e5e2fb1f --- /dev/null +++ b/resources/views/supportedapps/plexpy.blade.app @@ -0,0 +1,11 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }})

+
+ +
+ + {!! Form::text('config[apikey]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item')) !!} +
+
+ +
+
From 58bb9f1ea26d8076603255f90d167ee015f6950a Mon Sep 17 00:00:00 2001 From: mrquatsch Date: Sat, 17 Feb 2018 08:59:47 -0600 Subject: [PATCH 2/5] Updated to be enhanced --- app/SupportedApps/Plexpy.php | 69 ++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/app/SupportedApps/Plexpy.php b/app/SupportedApps/Plexpy.php index 212c3dd1..4b044fac 100644 --- a/app/SupportedApps/Plexpy.php +++ b/app/SupportedApps/Plexpy.php @@ -1,6 +1,12 @@ buildRequest('arnold'); + switch($res->getStatusCode()) { + case 200: + $data = json_decode($res->getBody()); + if(isset($data->error) && !empty($data->error)) { + echo 'Failed: '.$data->error; + } else { + echo 'Successfully connected to the API'; + } + break; + case 401: + echo 'Failed: Invalid credentials'; + break; + case 404: + echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; + break; + default: + echo 'Something went wrong... Code: '.$res->getStatusCode(); + break; + } + } + public function executeConfig() + { + $output = ''; + $res = $this->buildRequest('get_activity'); + $data = json_decode($res->getBody()); + $stream_count = $data->response->data->stream_count; + + $output = ' + + '; + + return $output; + } + public function buildRequest($endpoint) + { + $config = $this->config; + $url = $config->url; + $apikey = $config->apikey; + + $url = rtrim($url, '/'); + + $api_url = $url.'/api/v2?apikey='.$apikey.'&cmd='.$endpoint; + //die( $api_url.' --- '); + + $client = new Client(['http_errors' => false]); + $res = $client->request('GET', $api_url); + return $res; + + } + +} From 61793bd81d0939f56e63ae9c99065da303c80352 Mon Sep 17 00:00:00 2001 From: mrquatsch Date: Sun, 18 Feb 2018 08:36:05 -0600 Subject: [PATCH 3/5] Add Runeaudio as a supported app --- app/Item.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Item.php b/app/Item.php index c359a040..133d74d9 100644 --- a/app/Item.php +++ b/app/Item.php @@ -50,6 +50,7 @@ class Item extends Model 'Portainer' => \App\SupportedApps\Portainer::class, 'Proxmox' => \App\SupportedApps\Proxmox::class, 'Radarr' => \App\SupportedApps\Radarr::class, + 'Runeaudio' => \App\SupportedApps\Runeaudio::class, 'Sabnzbd' => \App\SupportedApps\Sabnzbd::class, 'Sonarr' => \App\SupportedApps\Sonarr::class, 'Traefik' => \App\SupportedApps\Traefik::class, From 3b1a4c1f2259d9ba1653b0d01e4cbd4634fe5e59 Mon Sep 17 00:00:00 2001 From: mrquatsch Date: Sun, 18 Feb 2018 08:36:45 -0600 Subject: [PATCH 4/5] Create Runeaudio enhanced app --- app/SupportedApps/Runeaudio.php | 89 +++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/SupportedApps/Runeaudio.php diff --git a/app/SupportedApps/Runeaudio.php b/app/SupportedApps/Runeaudio.php new file mode 100644 index 00000000..a5ed561b --- /dev/null +++ b/app/SupportedApps/Runeaudio.php @@ -0,0 +1,89 @@ +buildRequest('status'); + switch($res->getStatusCode()) { + case 200: + echo 'Successfully connected to the API'; + break; + case 401: + echo 'Failed: Invalid credentials'; + break; + case 404: + echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; + break; + default: + echo 'Something went wrong... Code: '.$res->getStatusCode(); + break; + } + } + + public function executeConfig() + { + $output = ''; + $artist = ''; + $song_title = ''; + $res = $this->buildRequest('currentsong'); + $array = explode("\n", $res->getBody()); + foreach($array as $item) { + $item_array = explode(": ", $item); + if ($item_array[0] == 'Artist') { + $artist = $item_array[1]; + if (strlen($artist) > 15) { + $artist = substr($artist,0,12).'...'; + } + } elseif ($item_array[0] == 'Title') { + $song_title = $item_array[1]; + if (strlen($song_title) > 15) { + $song_title = substr($song_title,0,12).'...'; + } + } + } + + $output = ' +
    +
  • Artist'.$artist.'
  • +
  • Song'.$song_title.'
  • +
+ '; + + return $output; + } + + public function buildRequest($endpoint) + { + $config = $this->config; + $url = $config->url; + + $url = rtrim($url, '/'); + + $api_url = $url.'/command/?cmd='.$endpoint; + //die( $api_url.' --- '); + + $client = new Client(['http_errors' => false]); + $res = $client->request('GET', $api_url); + return $res; + + } + + +} From 53a10944a9d03f58f70521f126f5ae31f0b6ef76 Mon Sep 17 00:00:00 2001 From: mrquatsch Date: Sun, 18 Feb 2018 08:37:29 -0600 Subject: [PATCH 5/5] Runeaudio app enhanced config --- .../views/supportedapps/runeaudio.blade.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 resources/views/supportedapps/runeaudio.blade.php diff --git a/resources/views/supportedapps/runeaudio.blade.php b/resources/views/supportedapps/runeaudio.blade.php new file mode 100644 index 00000000..e0a6b92f --- /dev/null +++ b/resources/views/supportedapps/runeaudio.blade.php @@ -0,0 +1,21 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }})

+
+ + +
+ + {!! Form::hidden('config[enabled]', '0') !!} + +
+
+ +
+