causefx 8 lat temu
rodzic
commit
b43d61df41

+ 8 - 0
api/config/default.php

@@ -33,6 +33,10 @@ return array(
     'ssoTautulli' => false,
 	'sonarrURL' => '',
 	'sonarrToken' => '',
+    'radarrURL' => '',
+	'radarrToken' => '',
+    'sickrageURL' => '',
+	'sickrageToken' => '',
 	'sabnzbdURL' => '',
     'sabnzbdToken' => '',
     'nzbgetURL' => '',
@@ -52,6 +56,10 @@ return array(
     'homepageSabnzbdAuth' => '1',
 	'homepageSonarrEnabled' => false,
     'homepageSonarrAuth' => '1',
+    'homepageSickrageEnabled' => false,
+    'homepageSickrageAuth' => '1',
+    'homepageRadarrEnabled' => false,
+    'homepageRadarrAuth' => '1',
     'homepageTransmissionEnabled' => false,
     'homepageTransmissionAuth' => '1',
     'homepageqBittorrentEnabled' => false,

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

@@ -682,7 +682,6 @@ function getCalendar(){
                 try {
                     $sonarr = new Kryptonit3\Sonarr\Sonarr($value['url'], $value['token']);
                     $sonarrCalendar = getSonarrCalendar($sonarr->getCalendar($startDate, $endDate),$key);
-
                 } catch (Exception $e) {
                     writeLog('error', 'Sonarr Connect Function - Error: '.$e->getMessage(), 'SYSTEM');
                 }
@@ -690,6 +689,54 @@ function getCalendar(){
             }
         }
     }
+    // RADARR CONNECT
+    if($GLOBALS['homepageRadarrEnabled'] && qualifyRequest($GLOBALS['homepageRadarrAuth']) && !empty($GLOBALS['radarrURL']) && !empty($GLOBALS['radarrToken'])){
+        $radarrs = array();
+        $radarrURLList = explode(',', $GLOBALS['radarrURL']);
+        $radarrTokenList = explode(',', $GLOBALS['radarrToken']);
+        if(count($radarrURLList) == count($radarrTokenList)){
+            foreach ($radarrURLList as $key => $value) {
+                $radarrs[$key] = array(
+                    'url' => $value,
+                    'token' => $radarrTokenList[$key]
+                );
+            }
+            foreach ($radarrs as $key => $value) {
+                try {
+                    $radarr = new Kryptonit3\Sonarr\Sonarr($value['url'], $value['token']);
+                    $radarrCalendar = getRadarrCalendar($radarr->getCalendar($startDate, $endDate),$key);
+                } catch (Exception $e) {
+                    writeLog('error', 'Radarr Connect Function - Error: '.$e->getMessage(), 'SYSTEM');
+                }
+                if(!empty($radarrCalendar)) { $calendarItems = array_merge($calendarItems, $radarrCalendar); }
+            }
+        }
+    }
+    // SICKRAGE/BEARD/MEDUSA CONNECT
+    if($GLOBALS['homepageSickrageEnabled'] && qualifyRequest($GLOBALS['homepageSickrageAuth']) && !empty($GLOBALS['sickrageURL']) && !empty($GLOBALS['sickrageToken'])){
+        $sicks = array();
+        $sickURLList = explode(',', $GLOBALS['sickrageURL']);
+        $sickTokenList = explode(',', $GLOBALS['sickrageToken']);
+        if(count($sickURLList) == count($sickTokenList)){
+            foreach ($sickURLList as $key => $value) {
+                $sicks[$key] = array(
+                    'url' => $value,
+                    'token' => $sickTokenList[$key]
+                );
+            }
+            foreach ($sicks as $key => $value) {
+                try {
+                    $sickrage = new Kryptonit3\SickRage\SickRage($value['url'], $value['token']);
+        			$sickrageFuture = getSickrageCalendarWanted($sickrage->future(),$key);
+                    $sickrageHistory = getSickrageCalendarHistory($sickrage->history("100","downloaded"),$key);
+        			if(!empty($sickrageFuture)) { $calendarItems = array_merge($calendarItems, $sickrageFuture); }
+                    if(!empty($sickrageHistory)) { $calendarItems = array_merge($calendarItems, $sickrageHistory); }
+        		} catch (Exception $e) {
+        			writeLog('error', 'Sickrage Connect Function - Error: '.$e->getMessage(), 'SYSTEM');
+        		}
+            }
+        }
+    }
 
 
 	return ($calendarItems) ? $calendarItems : false;
@@ -721,3 +768,136 @@ function getSonarrCalendar($array,$number){
     }
     if ($i != 0){ return $gotCalendar; }
 }
+function getRadarrCalendar($array,$number){
+    $array = json_decode($array, true);
+    $gotCalendar = array();
+    $i = 0;
+    foreach($array AS $child) {
+        if(isset($child['physicalRelease'])){
+            $i++;
+            $movieName = $child['title'];
+            $movieID = $child['tmdbId'];
+            if(!isset($movieID)){ $movieID = ""; }
+			$physicalRelease = $child['physicalRelease'];
+			$physicalRelease = strtotime($physicalRelease);
+			$physicalRelease = date("Y-m-d", $physicalRelease);
+			if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
+			$downloaded = $child['hasFile'];
+			if($downloaded == "0" && $notReleased == "true"){ $downloaded = "bg-info"; }elseif($downloaded == "1"){ $downloaded = "bg-success"; }else{ $downloaded = "bg-danger"; }
+			array_push($gotCalendar, array(
+				"id" => "Radarr-".$number."-".$i,
+				"title" => $movieName,
+				"start" => $child['physicalRelease'],
+				"className" => $downloaded." movieID--".$movieID,
+				"imagetype" => "film",
+			));
+        }
+    }
+    if ($i != 0){ return $gotCalendar; }
+}
+function getSickrageCalendarWanted($array,$number){
+    $array = json_decode($array, true);
+    $gotCalendar = array();
+    $i = 0;
+    foreach($array['data']['missed'] AS $child) {
+            $i++;
+            $seriesName = $child['show_name'];
+            $episodeID = $child['tvdbid'];
+            $episodeAirDate = $child['airdate'];
+            $episodeAirDateTime = explode(" ",$child['airs']);
+            $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
+            $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
+            $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
+            if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
+            $downloaded = "0";
+            if($downloaded == "0" && isset($unaired)){ $downloaded = "bg-info"; }elseif($downloaded == "1"){ $downloaded = "bg-success";}else{ $downloaded = "bg-danger"; }
+			array_push($gotCalendar, array(
+				"id" => "Sick-".$number."-Miss-".$i,
+				"title" => $seriesName,
+				"start" => $episodeAirDate,
+				"className" => $downloaded." tvID--".$episodeID,
+				"imagetype" => "tv",
+			));
+    }
+    foreach($array['data']['today'] AS $child) {
+            $i++;
+            $seriesName = $child['show_name'];
+            $episodeID = $child['tvdbid'];
+            $episodeAirDate = $child['airdate'];
+            $episodeAirDateTime = explode(" ",$child['airs']);
+            $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
+            $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
+            $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
+            if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
+            $downloaded = "0";
+            if($downloaded == "0" && isset($unaired)){ $downloaded = "bg-info"; }elseif($downloaded == "1"){ $downloaded = "bg-success";}else{ $downloaded = "bg-danger"; }
+			array_push($gotCalendar, array(
+				"id" => "Sick-".$number."-Today-".$i,
+				"title" => $seriesName,
+				"start" => $episodeAirDate,
+				"className" => $downloaded." tvID--".$episodeID,
+				"imagetype" => "tv",
+			));
+    }
+    foreach($array['data']['soon'] AS $child) {
+            $i++;
+            $seriesName = $child['show_name'];
+            $episodeID = $child['tvdbid'];
+            $episodeAirDate = $child['airdate'];
+            $episodeAirDateTime = explode(" ",$child['airs']);
+            $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
+            $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
+            $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
+            if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
+            $downloaded = "0";
+            if($downloaded == "0" && isset($unaired)){ $downloaded = "bg-info"; }elseif($downloaded == "1"){ $downloaded = "bg-success";}else{ $downloaded = "bg-danger"; }
+			array_push($gotCalendar, array(
+				"id" => "Sick-".$number."-Soon-".$i,
+				"title" => $seriesName,
+				"start" => $episodeAirDate,
+				"className" => $downloaded." tvID--".$episodeID,
+				"imagetype" => "tv",
+			));
+    }
+    foreach($array['data']['later'] AS $child) {
+            $i++;
+            $seriesName = $child['show_name'];
+            $episodeID = $child['tvdbid'];
+            $episodeAirDate = $child['airdate'];
+            $episodeAirDateTime = explode(" ",$child['airs']);
+            $episodeAirDateTime = date("H:i:s", strtotime($episodeAirDateTime[1].$episodeAirDateTime[2]));
+            $episodeAirDate = strtotime($episodeAirDate.$episodeAirDateTime);
+            $episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
+            if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
+            $downloaded = "0";
+            if($downloaded == "0" && isset($unaired)){ $downloaded = "bg-info"; }elseif($downloaded == "1"){ $downloaded = "bg-success";}else{ $downloaded = "bg-danger"; }
+			array_push($gotCalendar, array(
+				"id" => "Sick-".$number."-Later-".$i,
+				"title" => $seriesName,
+				"start" => $episodeAirDate,
+				"className" => $downloaded." tvID--".$episodeID,
+				"imagetype" => "tv",
+			));
+    }
+    if ($i != 0){ return $gotCalendar; }
+}
+function getSickrageCalendarHistory($array,$number){
+    $array = json_decode($array, true);
+    $gotCalendar = array();
+    $i = 0;
+    foreach($array['data'] AS $child) {
+            $i++;
+            $seriesName = $child['show_name'];
+            $episodeID = $child['tvdbid'];
+            $episodeAirDate = $child['date'];
+            $downloaded = "bg-success";
+			array_push($gotCalendar, array(
+				"id" => "Sick-".$number."-History-".$i,
+				"title" => $seriesName,
+				"start" => $episodeAirDate,
+				"className" => $downloaded." tvID--".$episodeID,
+				"imagetype" => "tv",
+			));
+    }
+    if ($i != 0){ return $gotCalendar; }
+}

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

@@ -829,6 +829,156 @@ function getHomepageList(){
                     )
                 )
             )
+        ),
+		array(
+            'name' => 'Radarr',
+            'enabled' => false,
+            'image' => 'plugins/images/tabs/radarr.png',
+            'category' => 'PVR',
+            'settings' => array(
+                'Enable' => array(
+                    array(
+                        'type' => 'switch',
+                        'name' => 'homepageRadarrEnabled',
+                        'label' => 'Enable',
+                        'value' => $GLOBALS['homepageRadarrEnabled']
+                    ),
+                    array(
+                        'type' => 'select',
+                        'name' => 'homepageRadarrAuth',
+                        'label' => 'Minimum Authentication',
+                        'value' => $GLOBALS['homepageRadarrAuth'],
+                        'options' => $groups
+                    )
+                ),
+                'Connection' => array(
+                    array(
+                        'type' => 'input',
+                        'name' => 'radarrURL',
+                        'label' => 'URL',
+                        'value' => $GLOBALS['radarrURL'],
+                        'placeholder' => 'http(s)://hostname:port'
+                    ),
+                    array(
+                        'type' => 'input',
+                        'name' => 'radarrToken',
+                        'label' => 'Token',
+                        'value' => $GLOBALS['radarrToken']
+                    )
+                ),
+                'Misc Options' => array(
+					array(
+						'type' => 'input',
+						'name' => 'calendarStart',
+						'label' => '# of Days Before',
+						'value' => $GLOBALS['calendarStart'],
+						'placeholder' => ''
+					),
+					array(
+						'type' => 'input',
+						'name' => 'calendarEnd',
+						'label' => '# of Days After',
+						'value' => $GLOBALS['calendarEnd'],
+						'placeholder' => ''
+					),
+					array(
+                        'type' => 'select',
+                        'name' => 'calendarFirstDay',
+                        'label' => 'Start Day',
+                        'value' => $GLOBALS['calendarFirstDay'],
+                        'options' => $day
+                    ),
+					array(
+                        'type' => 'select',
+                        'name' => 'calendarDefault',
+                        'label' => 'Default View',
+                        'value' => $GLOBALS['calendarDefault'],
+                        'options' => $calendarDefault
+                    ),
+					array(
+                        'type' => 'select',
+                        'name' => 'calendarTimeFormat',
+                        'label' => 'Time Format',
+                        'value' => $GLOBALS['calendarTimeFormat'],
+                        'options' => $timeFormat
+                    ),
+                    array(
+                        'type' => 'select',
+                        'name' => 'calendarRefresh',
+                        'label' => 'Refresh Seconds',
+                        'value' => $GLOBALS['calendarRefresh'],
+                        'options' => $time
+                    )
+                )
+            )
+        ),
+		array(
+            'name' => 'SickRage',
+            'enabled' => false,
+            'image' => 'plugins/images/tabs/sickrage.png',
+            'category' => 'PVR',
+            'settings' => array(
+                'Enable' => array(
+                    array(
+                        'type' => 'switch',
+                        'name' => 'homepageSickrageEnabled',
+                        'label' => 'Enable',
+                        'value' => $GLOBALS['homepageSickrageEnabled']
+                    ),
+                    array(
+                        'type' => 'select',
+                        'name' => 'homepageSickrageAuth',
+                        'label' => 'Minimum Authentication',
+                        'value' => $GLOBALS['homepageSickrageAuth'],
+                        'options' => $groups
+                    )
+                ),
+                'Connection' => array(
+                    array(
+                        'type' => 'input',
+                        'name' => 'sickrageURL',
+                        'label' => 'URL',
+                        'value' => $GLOBALS['sickrageURL'],
+                        'placeholder' => 'http(s)://hostname:port'
+                    ),
+                    array(
+                        'type' => 'input',
+                        'name' => 'sickrageToken',
+                        'label' => 'Token',
+                        'value' => $GLOBALS['sickrageToken']
+                    )
+                ),
+                'Misc Options' => array(
+					array(
+                        'type' => 'select',
+                        'name' => 'calendarFirstDay',
+                        'label' => 'Start Day',
+                        'value' => $GLOBALS['calendarFirstDay'],
+                        'options' => $day
+                    ),
+					array(
+                        'type' => 'select',
+                        'name' => 'calendarDefault',
+                        'label' => 'Default View',
+                        'value' => $GLOBALS['calendarDefault'],
+                        'options' => $calendarDefault
+                    ),
+					array(
+                        'type' => 'select',
+                        'name' => 'calendarTimeFormat',
+                        'label' => 'Time Format',
+                        'value' => $GLOBALS['calendarTimeFormat'],
+                        'options' => $timeFormat
+                    ),
+                    array(
+                        'type' => 'select',
+                        'name' => 'calendarRefresh',
+                        'label' => 'Refresh Seconds',
+                        'value' => $GLOBALS['calendarRefresh'],
+                        'options' => $time
+                    )
+                )
+            )
         )
     );
 }

+ 14 - 0
api/pages/homepage.php

@@ -40,6 +40,20 @@ $pageHomepage = '
             eventLimit: false, // allow "more" link when too many events
             selectable: false,
             height: "auto",
+            eventRender: function eventRender( event, element, view ) {
+            	if (typeof filter !== "undefined") {
+            		if(filter === "all"){
+            			return event.imagetype === event.imagetype;
+            		}else if(filter !== "all"){
+            			return filter === event.imagetype;
+            		}
+            		if(filter === null){
+            			return event.imagetype === event.imagetype;
+            		}
+            	}else {
+            		return event.imagetype === event.imagetype;
+            	}
+            },
         });
     },
    //init CalendarApp

+ 0 - 1
api/pages/settings.php

@@ -2,7 +2,6 @@
 if(file_exists('config'.DIRECTORY_SEPARATOR.'config.php')){
 $pageSettings = '
 <script>
-
     (function() {
         updateCheck();
         [].slice.call(document.querySelectorAll(\'.sttabs\')).forEach(function(el) {