Parcourir la source

Added default TV request settings for Ombi

causefx il y a 7 ans
Parent
commit
99a1bcfa12

+ 1 - 0
api/config/default.php

@@ -123,6 +123,7 @@ return array(
 	'homepageOmbiRequestAuth' => '1',
 	'ombiLimitUser' => false,
 	'ombiRefresh' => '600000',
+	'ombiTvDefault' => 'all',
 	'homepageOrdercustomhtml' => '1',
 	'homepageOrdercustomhtmlTwo' => '2',
 	'homepageOrdertransmission' => '3',

+ 11 - 6
api/functions/homepage-connect-functions.php

@@ -484,10 +484,15 @@ function plexConnect($action, $key = null)
 	if ($GLOBALS['homepagePlexEnabled'] && !empty($GLOBALS['plexURL']) && !empty($GLOBALS['plexToken']) && !empty($GLOBALS['plexID'] && qualifyRequest($GLOBALS['homepagePlexAuth']))) {
 		$url = qualifyURL($GLOBALS['plexURL']);
 		$ignore = array();
+		$resolve = true;
 		switch ($action) {
 			case 'streams':
 				$url = $url . "/status/sessions?X-Plex-Token=" . $GLOBALS['plexToken'];
 				break;
+			case 'libraries':
+				$url = $url . "/library/sections?X-Plex-Token=" . $GLOBALS['plexToken'];
+				$resolve = false;
+				break;
 			case 'recent':
 				$url = $url . "/library/recentlyAdded?X-Plex-Token=" . $GLOBALS['plexToken'] . "&limit=" . $GLOBALS['homepageRecentLimit'];
 				break;
@@ -517,7 +522,7 @@ function plexConnect($action, $key = null)
 						$items[] = resolvePlexItem($child);
 					}
 				}
-				$api['content'] = $items;
+				$api['content'] = ($resolve) ? $items : $plex;
 				$api['plexID'] = $GLOBALS['plexID'];
 				$api['showNames'] = true;
 				$api['group'] = '1';
@@ -1782,7 +1787,7 @@ function getSickrageCalendarHistory($array, $number)
 
 function ombiAPI($array)
 {
-	return ombiAction($array['data']['id'], $array['data']['action'], $array['data']['type']);
+	return ombiAction($array['data']['id'], $array['data']['action'], $array['data']['type'], $array['data']);
 }
 
 function ombiImport($type = null)
@@ -1824,7 +1829,7 @@ function ombiImport($type = null)
 	return false;
 }
 
-function ombiAction($id, $action, $type)
+function ombiAction($id, $action, $type, $fullArray = null)
 {
 	if ($GLOBALS['homepageOmbiEnabled'] && !empty($GLOBALS['ombiURL']) && !empty($GLOBALS['ombiToken']) && qualifyRequest($GLOBALS['homepageOmbiAuth'])) {
 		$url = qualifyURL($GLOBALS['ombiURL']);
@@ -1842,9 +1847,9 @@ function ombiAction($id, $action, $type)
 				$type = 'tv';
 				$add = array(
 					'tvDbId' => $id,
-					'requestAll' => true,
-					'latestSeason' => true,
-					'firstSeason' => true
+					'requestAll' => ombiTVDefault('all'),
+					'latestSeason' => ombiTVDefault('last'),
+					'firstSeason' => ombiTVDefault('first')
 				);
 				break;
 			default:

+ 36 - 0
api/functions/homepage-functions.php

@@ -290,6 +290,20 @@ function buildHomepageItem($homepageItem)
 function getHomepageList()
 {
 	$groups = groupSelect();
+	$ombiTvOptions = array(
+		array(
+			'name' => 'All Seasons',
+			'value' => 'all'
+		),
+		array(
+			'name' => 'First Season Only',
+			'value' => 'first'
+		),
+		array(
+			'name' => 'Last Season Only',
+			'value' => 'last'
+		),
+	);
 	$mediaServers = array(
 		array(
 			'name' => 'N/A',
@@ -1959,6 +1973,13 @@ function getHomepageList()
 						'value' => $GLOBALS['homepageOmbiRequestAuth'],
 						'options' => $groups
 					),
+					array(
+						'type' => 'select',
+						'name' => 'ombiTvDefault',
+						'label' => 'TV Show Default Request',
+						'value' => $GLOBALS['ombiTvDefault'],
+						'options' => $ombiTvOptions
+					),
 					array(
 						'type' => 'switch',
 						'name' => 'ombiLimitUser',
@@ -2175,3 +2196,18 @@ function buildHomepageSettings()
 	$inputList .= '</form>';
 	return $homepageList . $inputList;
 }
+
+function ombiTVDefault($type)
+{
+	switch ($type) {
+		case 'all':
+			return ($type == $GLOBALS['ombiTvDefault']) ? true : false;
+		case 'first':
+			return ($type == $GLOBALS['ombiTvDefault']) ? true : false;
+		case 'last':
+			return ($type == $GLOBALS['ombiTvDefault']) ? true : false;
+		default:
+			return false;
+	}
+	return false;
+}