Quellcode durchsuchen

fixed sonarr queue title issue
fixed radarr queue combining issue

CauseFX vor 4 Jahren
Ursprung
Commit
bab587a817
4 geänderte Dateien mit 27 neuen und 23 gelöschten Zeilen
  1. 10 11
      api/homepage/radarr.php
  2. 9 9
      api/homepage/sonarr.php
  3. 5 1
      api/vendor/kryptonit3/sonarr/src/Sonarr.php
  4. 3 2
      js/functions.js

+ 10 - 11
api/homepage/radarr.php

@@ -61,7 +61,7 @@ trait RadarrHomepageItem
 		];
 		return array_merge($homepageInformation, $homepageSettings);
 	}
-	
+
 	public function testConnectionRadarr()
 	{
 		if (empty($this->config['radarrURL'])) {
@@ -93,7 +93,6 @@ trait RadarrHomepageItem
 					$errors .= $ip . ': Response was not JSON';
 					$failed = true;
 				}
-				
 			} catch (Exception $e) {
 				$failed = true;
 				$ip = $value['url'];
@@ -109,7 +108,7 @@ trait RadarrHomepageItem
 			return true;
 		}
 	}
-	
+
 	public function radarrHomepagePermissions($key = null)
 	{
 		$permissions = [
@@ -142,7 +141,7 @@ trait RadarrHomepageItem
 		];
 		return $this->homepageCheckKeyPermissions($key, $permissions);
 	}
-	
+
 	public function homepageOrderRadarrQueue()
 	{
 		if ($this->homepageItemPermissions($this->radarrHomepagePermissions('queue'))) {
@@ -161,7 +160,7 @@ trait RadarrHomepageItem
 				';
 		}
 	}
-	
+
 	public function getRadarrQueue()
 	{
 		if (!$this->homepageItemPermissions($this->radarrHomepagePermissions('queue'), true)) {
@@ -177,6 +176,7 @@ trait RadarrHomepageItem
 				$downloadList = json_decode($results, true);
 				if (is_array($downloadList) || is_object($downloadList)) {
 					$queue = (array_key_exists('error', $downloadList)) ? '' : $downloadList;
+					$queue = $queue['records'] ?? $queue;
 				} else {
 					$queue = '';
 				}
@@ -184,16 +184,16 @@ trait RadarrHomepageItem
 					$queueItems = array_merge($queueItems, $queue);
 				}
 			} catch (Exception $e) {
-				$this->writeLog('error', 'Radarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
+				$this->logger->error($e);
 			}
 		}
 		$api['content']['queueItems'] = $queueItems;
 		$api['content']['historyItems'] = false;
-		$api['content'] = isset($api['content']) ? $api['content'] : false;
+		$api['content'] = $api['content'] ?? false;
 		$this->setAPIResponse('success', null, 200, $api);
-		return $api;;
+		return $api;
 	}
-	
+
 	public function getRadarrCalendar($startDate = null, $endDate = null)
 	{
 		$startDate = ($startDate) ?? $_GET['start'] ?? date('Y-m-d', strtotime('-' . $this->config['calendarStart'] . ' days'));
@@ -227,7 +227,7 @@ trait RadarrHomepageItem
 		$this->setAPIResponse('success', null, 200, $calendarItems);
 		return $calendarItems;
 	}
-	
+
 	public function formatRadarrCalendar($array, $number, $url)
 	{
 		$url = rtrim($url, '/'); //remove trailing slash
@@ -298,7 +298,6 @@ trait RadarrHomepageItem
 						} else {
 							$banner = $image['url'];
 						}
-						
 					}
 				}
 				if ($banner !== "/plugins/images/cache/no-np.png" || (strpos($banner, 'apikey') !== false)) {

+ 9 - 9
api/homepage/sonarr.php

@@ -62,7 +62,7 @@ trait SonarrHomepageItem
 		];
 		return array_merge($homepageInformation, $homepageSettings);
 	}
-	
+
 	public function testConnectionSonarr()
 	{
 		if (empty($this->config['sonarrURL'])) {
@@ -94,7 +94,6 @@ trait SonarrHomepageItem
 					$errors .= $ip . ': Response was not JSON';
 					$failed = true;
 				}
-				
 			} catch (Exception $e) {
 				$failed = true;
 				$ip = $value['url'];
@@ -110,7 +109,7 @@ trait SonarrHomepageItem
 			return true;
 		}
 	}
-	
+
 	public function sonarrHomepagePermissions($key = null)
 	{
 		$permissions = [
@@ -143,7 +142,7 @@ trait SonarrHomepageItem
 		];
 		return $this->homepageCheckKeyPermissions($key, $permissions);
 	}
-	
+
 	public function homepageOrderSonarrQueue()
 	{
 		if ($this->homepageItemPermissions($this->sonarrHomepagePermissions('queue'))) {
@@ -162,7 +161,7 @@ trait SonarrHomepageItem
 				';
 		}
 	}
-	
+
 	public function getSonarrQueue()
 	{
 		if (!$this->homepageItemPermissions($this->sonarrHomepagePermissions('queue'), true)) {
@@ -178,6 +177,7 @@ trait SonarrHomepageItem
 				$downloadList = json_decode($results, true);
 				if (is_array($downloadList) || is_object($downloadList)) {
 					$queue = (array_key_exists('error', $downloadList)) ? '' : $downloadList;
+					$queue = $queue['records'] ?? $queue;
 				} else {
 					$queue = '';
 				}
@@ -190,11 +190,11 @@ trait SonarrHomepageItem
 		}
 		$api['content']['queueItems'] = $queueItems;
 		$api['content']['historyItems'] = false;
-		$api['content'] = isset($api['content']) ? $api['content'] : false;
+		$api['content'] = $api['content'] ?? false;
 		$this->setAPIResponse('success', null, 200, $api);
-		return $api;;
+		return $api;
 	}
-	
+
 	public function getSonarrCalendar($startDate = null, $endDate = null)
 	{
 		$startDate = ($startDate) ?? $_GET['start'] ?? date('Y-m-d', strtotime('-' . $this->config['calendarStart'] . ' days'));
@@ -228,7 +228,7 @@ trait SonarrHomepageItem
 		$this->setAPIResponse('success', null, 200, $calendarItems);
 		return $calendarItems;
 	}
-	
+
 	public function formatSonarrCalendar($array, $number)
 	{
 		$array = json_decode($array, true);

+ 5 - 1
api/vendor/kryptonit3/sonarr/src/Sonarr.php

@@ -341,9 +341,13 @@ class Sonarr
             'uri' => $uri,
             'type' => 'get',
             'data' => [
-            	'includeUnknownSeriesItems' => 'false'
+            	'includeUnknownSeriesItems' => 'false',
             ]
         ];
+	    if ( $this->type == 'sonarr' ) {
+		    $response['data']['includeSeries'] = 'true';
+		    $response['data']['includeEpisode'] = 'true';
+	    }
 
         return $this->processRequest($response);
     }

+ 3 - 2
js/functions.js

@@ -6511,12 +6511,13 @@ function buildDownloaderItem(array, source, type='none'){
 				queue = '<tr><td class="max-texts" lang="en">Nothing in queue</td></tr>';
 				break;
 			}
-			$.each(array.content.queueItems, function(i,v) {
+            let sonarrQueueSet = (typeof array.content.queueItems.records == 'undefined') ? array.content.queueItems : array.content.queueItems.records;
+			$.each(sonarrQueueSet, function(i,v) {
 				count = count + 1;
 				var percent = Math.floor(((v.size - v.sizeleft) / v.size) * 100);
 				percent = (isNaN(percent)) ? '0' : percent;
 				var size = v.size != -1 ? humanFileSize(v.size,false) : "?";
-				v.name = v.series.title;
+                v.name = (typeof v.series == 'undefined') ? v.title : v.series.title;
 				queue += `
                 <tr>
                     <td class="">`+v.name+`</td>