Browse Source

Merge pull request #640 from causefx/cero-dev

Added Couchpotato
causefx 8 years ago
parent
commit
6da1e0a872
5 changed files with 82 additions and 5 deletions
  1. 3 0
      config/configDefaults.php
  2. 42 1
      functions.php
  3. 2 2
      homepage.php
  4. 1 1
      index.php
  5. 34 1
      settings.php

+ 3 - 0
config/configDefaults.php

@@ -96,4 +96,7 @@ return array(
 	"installedTheme" => "",
 	"calendarRefresh" => "60000",
 	"authBackendDomainFormat" => "",
+	"couchURL" => "",
+	"couchAPI" => "",
+	"couchHomeAuth" => false,
 );

+ 42 - 1
functions.php

@@ -2533,7 +2533,7 @@ function nzbgetConnect($list = 'listgroups') {
 			return '<tr><td colspan="4"><p class="text-center">No Results</p></td></tr>';
 		}
 	}else{
-		writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Usernamd and Password - if HTTPS, is cert valid");
+		writeLog("error", "NZBGET ERROR: could not connect - check URL and/or check token and/or Username and Password - if HTTPS, is cert valid");
 	}
 }
 
@@ -3021,6 +3021,42 @@ function getSonarrCalendar($array){
 
 }
 
+function getCouchCalendar(){
+	$url = qualifyURL(COUCHURL);    
+    $api = curl_get($url."/api/".COUCHAPI."/media.list");
+    $api = json_decode($api, true);
+    $i = 0;
+    $gotCalendar = array();
+	if (is_array($api) || is_object($api)){
+		foreach($api['movies'] AS $child) {
+			if($child['status'] == "active" || $child['status'] == "done" ){
+				$i++;
+				$movieName = $child['info']['original_title'];
+				$movieID = $child['info']['tmdb_id'];
+				if(!isset($movieID)){ $movieID = ""; }
+				$physicalRelease = (isset($child['info']['released']) ? $child['info']['released'] : null); 
+				$backupRelease = (isset($child['info']['release_date']['theater']) ? $child['info']['release_date']['theater'] : null); 
+				$physicalRelease = (isset($physicalRelease) ? $physicalRelease : $backupRelease);
+				$physicalRelease = strtotime($physicalRelease);
+				$physicalRelease = date("Y-m-d", $physicalRelease);
+				if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
+				$downloaded = ($child['status'] == "active") ? "0" : "1";
+				if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
+				array_push($gotCalendar, array(
+					"id" => "CouchPotato-".$i,
+					"title" => $movieName, 
+					"start" => $physicalRelease, 
+					"className" => $downloaded." movieID--".$movieID, 
+					"imagetype" => "film",
+				));
+			}
+		}
+    	if ($i != 0){ return $gotCalendar; }
+	}else{
+		writeLog("error", "CouchPotato ERROR: could not connect - check URL and/or check API key - if HTTPS, is cert valid");
+	}
+}
+
 function getRadarrCalendar($array){  
     $array = json_decode($array, true);
     $gotCalendar = array();
@@ -4002,6 +4038,11 @@ function getCalendar(){
 			writeLog("error", "RADARR ERROR: ".strip($e->getMessage())); 
 		}
 	}
+	if (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH)){
+		$couchCalendar = getCouchCalendar(); 
+		if(!empty($couchCalendar)) { $calendarItems = array_merge($calendarItems, $couchCalendar); }
+
+	}
 	if (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)){
 		$headphonesHistory = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getHistory"); 
 		$headphonesWanted = getHeadphonesCalendar(HEADPHONESURL, HEADPHONESKEY, "getWanted"); 

+ 2 - 2
homepage.php

@@ -45,7 +45,7 @@ foreach(loadAppearance() as $key => $value) {
         <link rel="stylesheet" href="bower_components/google-material-color/dist/palette.css?v=<?php echo INSTALLEDVERSION; ?>">
         <link rel="stylesheet" type="text/css" href="bower_components/slick/slick.css?v=<?php echo INSTALLEDVERSION; ?>">
         <link rel="stylesheet" href="bower_components/sweetalert/dist/sweetalert.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/smoke/dist/css/smoke.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="bower_components/smoke/dist/css/smoke.min.css?v=<?php echo INSTALLEDVERSION; ?>">
         
        
 
@@ -451,7 +451,7 @@ foreach(loadAppearance() as $key => $value) {
 
                 </div>
 				<?php } ?>
-                <?php if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH))) { ?>
+                <?php if ((SONARRURL != "" && qualifyUser(SONARRHOMEAUTH)) || (RADARRURL != "" && qualifyUser(RADARRHOMEAUTH)) || (HEADPHONESURL != "" && qualifyUser(HEADPHONESHOMEAUTH)) || (SICKRAGEURL != "" && qualifyUser(SICKRAGEHOMEAUTH)) || (COUCHURL != "" && qualifyUser(COUCHHOMEAUTH))) { ?>
                 <div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">
                     <div class="col-lg-12 content-form form-inline">
                         <div class="form-group pull-right">

+ 1 - 1
index.php

@@ -486,7 +486,7 @@ if(file_exists("images/settings2.png")) : $iconRotate = "false"; $settingsIcon =
 			<div class="table-row">
 				<div class="table-cell">
 					<div class="la-ball-scale-multiple la-3x" style="color: <?=$topbar;?>">
-						<?php if (pathinfo($loadingIcon, PATHINFO_EXTENSION) !== "gif" ) : 
+						<?php if ($loadingIcon == "images/organizr-load-w-thick.gif") : 
 							echo "<div></div><div></div><div></div>";
 						endif; ?>
 						<logo class="logo"><img height="192px" src="<?=$loadingIcon;?>"></logo>

+ 34 - 1
settings.php

@@ -182,6 +182,9 @@ $themeVersion = (!empty(INSTALLEDTHEME) ? explode("-", INSTALLEDTHEME)[1] : null
 		</script>
 		
         <style>
+            body{
+                background: #273238;
+            }
             .save-btn-form {
                 position: absolute;
                 top: 15px;
@@ -344,7 +347,7 @@ $themeVersion = (!empty(INSTALLEDTHEME) ? explode("-", INSTALLEDTHEME)[1] : null
         </style>
     </head>
 
-    <body id="body-settings" class="scroller-body group-<?php echo $group;?>" style="padding: 0; background: #273238; overflow: hidden">
+    <body id="body-settings" class="scroller-body group-<?php echo $group;?>" style="padding: 0; overflow: hidden">
         <div id="main-wrapper" class="main-wrapper">
 
             <!--Content-->
@@ -1119,6 +1122,36 @@ echo buildSettings(
 						'value' => RADARRKEY,
 					),
 				),
+            ),
+            array(
+				'title' => 'CouchPotato',
+				'id' => 'couchpotato',
+				'image' => 'images/couchpotato.png',
+				'fields' => array(
+					array(
+						'type' => $userSelectType,
+						'labelTranslate' => 'SHOW_ON_HOMEPAGE',
+						'name' => 'couchHomeAuth',
+						'value' => COUCHHOMEAUTH,
+						'options' => $userTypes,
+					),
+					array(
+						'type' => 'text',
+						'placeholder' => 'http://hostname:8181',
+						'labelTranslate' => 'COUCH_URL',
+						'assist' => 'http://hostname:8181',
+						'name' => 'couchURL',
+						'pattern' => $urlPattern,
+						'value' => COUCHURL,
+					),
+					array(
+						'type' => 'text',
+						'placeholder' => randString(32),
+						'labelTranslate' => 'COUCH_KEY',
+						'name' => 'couchAPI',
+						'value' => COUCHAPI,
+					),
+				),
 			),
 			array(
 				'title' => 'Sickbeard/Sickrage',