Просмотр исходного кода

Add Sonarr unmonitored to Calendar

Matt Ohm 8 лет назад
Родитель
Сommit
0cdb4aeb0b

+ 4 - 1
api/functions/homepage-connect-functions.php

@@ -833,7 +833,7 @@ function getCalendar()
 			foreach ($sonarrs as $key => $value) {
 				try {
 					$sonarr = new Kryptonit3\Sonarr\Sonarr($value['url'], $value['token']);
-					$sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate), $key);
+					$sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate, $GLOBALS['sonarrUnmonitored']), $key);
 				} catch (Exception $e) {
 					writeLog('error', 'Sonarr Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');
 				}
@@ -935,6 +935,7 @@ function getSonarrCalendar($array, $number)
 		$seriesName = $child['series']['title'];
 		$seriesID = $child['series']['tvdbId'];
 		$episodeID = $child['series']['tvdbId'];
+		$monitored = $child['monitored'];
 		if (!isset($episodeID)) {
 			$episodeID = "";
 		}
@@ -953,6 +954,8 @@ function getSonarrCalendar($array, $number)
 		$downloaded = $child['hasFile'];
 		if ($downloaded == "0" && isset($unaired) && $episodePremier == "true") {
 			$downloaded = "text-primary animated flash";
+		} elseif ($downloaded == "0" && isset($unaired) && $monitored == "0") {
+			$downloaded = "text-dark";	
 		} elseif ($downloaded == "0" && isset($unaired)) {
 			$downloaded = "text-info";
 		} elseif ($downloaded == "1") {

+ 7 - 1
api/functions/homepage-functions.php

@@ -769,7 +769,7 @@ function getHomepageList()
 				'Test Connection' => array(
 					array(
 						'type' => 'blank',
-						'label' => 'Please save form before Test'
+						'label' => ''
 					),
 					array(
 						'type' => 'button',
@@ -1166,6 +1166,12 @@ function getHomepageList()
 						'label' => 'Refresh Seconds',
 						'value' => $GLOBALS['calendarRefresh'],
 						'options' => $time
+					),
+										array(
+						'type' => 'switch',
+						'name' => 'sonarrUnmonitored',
+						'label' => 'Show Unmonitored',
+						'value' => $GLOBALS['sonarrUnmonitored']
 					)
 				),
 				'Test Connection' => array(

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

@@ -29,7 +29,7 @@ class Sonarr
      * @param string|null $end
      * @return array|object|string
      */
-    public function getCalendar($start = null, $end = null)
+    public function getCalendar($start = null, $end = null, $sonarrUnmonitored = 'false')
     {
         $uriData = [];
 
@@ -61,7 +61,10 @@ class Sonarr
                 exit();
             }
         }
-
+        if ( $sonarrUnmonitored == 'true' ) {
+            $uriData['unmonitored'] = 'true';
+	}
+            
         $response = [
             'uri' => 'calendar',
             'type' => 'get',