Bläddra i källkod

Merge pull request #172 from causefx/develop

Added NZBGET to Homepage - Fix more bugs
causefx 9 år sedan
förälder
incheckning
b37c99dd8b
12 ändrade filer med 306 tillägg och 31 borttagningar
  1. 75 4
      functions.php
  2. 103 3
      homepage.php
  3. 4 8
      image.php
  4. 9 1
      lang/de.ini
  5. 9 1
      lang/en.ini
  6. 9 1
      lang/es.ini
  7. 9 1
      lang/fr.ini
  8. 9 1
      lang/it.ini
  9. 9 1
      lang/nl.ini
  10. 9 1
      lang/pl.ini
  11. 56 8
      settings.php
  12. 5 1
      user.php

+ 75 - 4
functions.php

@@ -208,7 +208,8 @@ function getPlexRecent($url, $port, $type, $token, $size, $header){
     
     $address = $url;
     
-    $api = simplexml_load_file($address."/library/recentlyAdded?X-Plex-Token=".$token);
+    $api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".$token);
+    $api = simplexml_load_string($api);
     
     $i = 0;
     
@@ -248,7 +249,7 @@ function getPlexRecent($url, $port, $type, $token, $size, $header){
             }
             
             
-            $gotPlex .= '<div class="item '.$active.'"><img class="carousel-image '.$type.'" src="image.php?img='.$address.$thumb.'&height='.$height.'&width='.$width.'"><div class="carousel-caption '.$type.'" style="overflow:auto"><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
+            $gotPlex .= '<div class="item '.$active.'"><img class="carousel-image '.$type.'" src="image.php?img='.$thumb.'&height='.$height.'&width='.$width.'"><div class="carousel-caption '.$type.'" style="overflow:auto"><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
 
         }
         
@@ -284,7 +285,8 @@ function getPlexStreams($url, $port, $token, $size, $header){
     
     $address = $url;
     
-    $api = simplexml_load_file($address."/status/sessions?X-Plex-Token=".$token);
+    $api = file_get_contents($address."/status/sessions?X-Plex-Token=".$token);
+    $api = simplexml_load_string($api);
     
     $i = 0;
     
@@ -333,7 +335,7 @@ function getPlexStreams($url, $port, $token, $size, $header){
 
         $gotPlex .= '<div class="item '.$active.'">';
 
-        $gotPlex .= "<img class='carousel-image $image' src='image.php?img=$address$thumb&height=$height&width=$width'>";
+        $gotPlex .= "<img class='carousel-image $image' src='image.php?img=$thumb&height=$height&width=$width'>";
 
         $gotPlex .= '<div class="carousel-caption '. $image . '" style="overflow:auto"><h4>'.$title.'</h4><small><em>'.$summary.'</em></small></div></div>';
 
@@ -454,4 +456,73 @@ function getRadarrCalendar($url, $port, $key){
 
 }
 
+function nzbgetConnect($url, $port, $username, $password, $list){
+    
+    $urlCheck = stripos($url, "http");
+
+    if ($urlCheck === false) {
+        
+        $url = "http://" . $url;
+    
+    }
+    
+    if($port !== ""){ $url = $url . ":" . $port; }
+    
+    $address = $url;
+    
+    $api = file_get_contents("$url/$username:$password/jsonrpc/$list");
+                    
+    $api = json_decode($api, true);
+    
+    $i = 0;
+    
+    $gotNZB = "";
+    
+    foreach ($api['result'] AS $child) {
+        
+        $i++;
+        //echo '<pre>' . var_export($child, true) . '</pre>';
+        $downloadName = $child['NZBName'];
+        $downloadStatus = $child['Status'];
+        $downloadCategory = $child['Category'];
+        if($list == "history"){ $downloadPercent = "100"; $progressBar = ""; }
+        if($list == "listgroups"){ $downloadPercent = (($child['FileSizeMB'] - $child['RemainingSizeMB']) / $child['FileSizeMB']) * 100; $progressBar = "progress-bar-striped active"; }
+        if($child['Health'] <= "750"){ 
+            $downloadHealth = "danger"; 
+        }elseif($child['Health'] <= "900"){ 
+            $downloadHealth = "warning"; 
+        }elseif($child['Health'] <= "1000"){ 
+            $downloadHealth = "success"; 
+        }
+        
+        $gotNZB .= '<tr>
+
+                        <td>'.$downloadName.'</td>
+                        <td>'.$downloadStatus.'</td>
+                        <td>'.$downloadCategory.'</td>
+
+                        <td>
+
+                            <div class="progress">
+
+                                <div class="progress-bar progress-bar-'.$downloadHealth.' '.$progressBar.'" role="progressbar" aria-valuenow="'.$downloadPercent.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$downloadPercent.'%">
+
+                                    <span class="sr-only">'.$downloadPercent.'% Complete</span>
+
+                                </div>
+
+                            </div>
+
+                        </td>
+
+                    </tr>';
+        
+        
+    }
+    
+    if($i > 0){ return $gotNZB; }
+
+}
+
+
 ?>

+ 103 - 3
homepage.php

@@ -182,7 +182,106 @@ endif; ?>
         <div class="main-wrapper" style="position: initial;">
             
             <div id="content" class="container-fluid">
-            
+                
+                <br>
+                <?php if(NZBGETURL != "") : ?>
+                <div class="row">
+
+                    <div class="col-md-12">
+
+                        <div class="tabbable panel with-nav-tabs panel-default">
+
+                            <div class="panel-heading">
+
+                                <h3 class="pull-left">NZBGet</h3>
+
+                                <ul class="nav nav-tabs pull-right">
+
+                                    <li class="active"><a href="#downloadQueue" data-toggle="tab" aria-expanded="true"><?php echo $language->translate("QUEUE");?></a></li>
+
+                                    <li class=""><a href="#downloadHistory" data-toggle="tab" aria-expanded="false"><?php echo $language->translate("HISTORY");?></a></li>
+
+                                </ul>
+
+                                <div class="clearfix"></div>
+
+                            </div>
+
+                            <div class="panel-body">
+
+                                <div class="tab-content">
+
+                                    <div class="tab-pane fade active in" id="downloadQueue">
+
+                                            <div class="table-responsive">
+
+                                                <table class="table table-striped progress-widget zero-m">
+
+                                                    <thead>
+
+                                                        <tr>
+
+                                                            <th><?php echo $language->translate("FILE");?></th>
+                                                            <th><?php echo $language->translate("STATUS");?></th>
+                                                            <th><?php echo $language->translate("CATEGORY");?></th>
+                                                            <th><?php echo $language->translate("PROGRESS");?></th>
+
+                                                        </tr>
+
+                                                    </thead>
+
+                                                    <tbody>
+                <?php echo nzbgetConnect(NZBGETURL, NZBGETPORT, NZBGETUSERNAME, NZBGETPASSWORD, "listgroups");?>                                   
+
+                                                    </tbody>
+
+                                                </table>
+
+                                            </div>
+
+                                    </div>
+
+                                    <div class="tab-pane fade" id="downloadHistory">
+
+                                        <div class="table-responsive">
+
+                                            <table class="table table-striped progress-widget zero-m">
+
+                                                <thead>
+
+                                                    <tr>
+
+                                                        <th>File</th>
+                                                        <th>Status</th>
+                                                        <th>Category</th>
+                                                        <th>Progress</th>
+
+                                                    </tr>
+
+                                                </thead>
+
+                                                <tbody>
+            <?php echo nzbgetConnect(NZBGETURL, NZBGETPORT, NZBGETUSERNAME, NZBGETPASSWORD, "history");?>                                        
+
+                                                </tbody>
+
+                                            </table>
+
+                                            </div>
+
+                                    </div>
+
+                                </div>
+
+                            </div>
+
+                        </div>
+
+                    </div>
+
+                </div>
+                <?php endif; ?>
+
                 <div class="row">
 
                     <?php
@@ -288,14 +387,15 @@ endif; ?>
                   //defaultDate: '2017-03-21',
 			      defaultView: 'basicWeek',
                 header: {
-                  left: 'prev, next',
+                  left: 'prev,next,',
                   center: 'title',
-                  right: 'month, basicDay,basicWeek,'
+                  right: 'today, month, basicDay,basicWeek,'
                 },
                 views: {
                     basicDay: { buttonText: '<?php echo $language->translate("DAY");?>', eventLimit: false },
                     basicWeek: { buttonText: '<?php echo $language->translate("WEEK");?>', eventLimit: false },
                     month: { buttonText: '<?php echo $language->translate("MONTH");?>', eventLimit: false },
+                    today: { buttonText: '<?php echo $language->translate("TODAY");?>' },
                 },
                 events: [
 

+ 4 - 8
image.php

@@ -20,20 +20,16 @@ if ($urlCheck === false) {
 
 if(PLEXPORT !== ""){ $plexAddress = $plexAddress . ":" . PLEXPORT; }
 
-//$plexAddress = PLEXURL.':'.PLEXPORT;
-
-$addressPosition = strpos($image_url, $plexAddress);
-
-if($addressPosition !== false && $addressPosition == 0) {
+if(isset($image_url) && isset($image_height) && isset($image_width)) {
     
 	$image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
-    
-	header('Content-type: image/jpeg');
+
+    header('Content-type: image/jpeg');
     
 	readfile($image_src);
     
 } else {
     
-    echo "Bad Plex Image Url";	
+    echo "Invalid Plex Request";	
     
 }

+ 9 - 1
lang/de.ini

@@ -191,4 +191,12 @@ RADARR_PORT = "Radarr Port"
 RADARR_KEY = "Radarr API Key"
 MONTH = "Month"
 DAY = "Day"
-WEEK = "Week"
+WEEK = "Week"
+NZBGET_URL = "NZBGet URL"
+NZBGET_PORT = "NZBGet Port"
+QUEUE = "Queue"
+HISTORY = "History"
+FILE = "File"
+STATUS = "Status"
+CATEGORY = "Category"
+PROGRESS = "Progress"

+ 9 - 1
lang/en.ini

@@ -191,4 +191,12 @@ RADARR_PORT = "Radarr Port"
 RADARR_KEY = "Radarr API Key"
 MONTH = "Month"
 DAY = "Day"
-WEEK = "Week"
+WEEK = "Week"
+NZBGET_URL = "NZBGet URL"
+NZBGET_PORT = "NZBGet Port"
+QUEUE = "Queue"
+HISTORY = "History"
+FILE = "File"
+STATUS = "Status"
+CATEGORY = "Category"
+PROGRESS = "Progress"

+ 9 - 1
lang/es.ini

@@ -191,4 +191,12 @@ RADARR_PORT = "Radarr Port"
 RADARR_KEY = "Radarr API Key"
 MONTH = "Month"
 DAY = "Day"
-WEEK = "Week"
+WEEK = "Week"
+NZBGET_URL = "NZBGet URL"
+NZBGET_PORT = "NZBGet Port"
+QUEUE = "Queue"
+HISTORY = "History"
+FILE = "File"
+STATUS = "Status"
+CATEGORY = "Category"
+PROGRESS = "Progress"

+ 9 - 1
lang/fr.ini

@@ -191,4 +191,12 @@ RADARR_PORT = "Radarr Port"
 RADARR_KEY = "Radarr API Key"
 MONTH = "Month"
 DAY = "Day"
-WEEK = "Week"
+WEEK = "Week"
+NZBGET_URL = "NZBGet URL"
+NZBGET_PORT = "NZBGet Port"
+QUEUE = "Queue"
+HISTORY = "History"
+FILE = "File"
+STATUS = "Status"
+CATEGORY = "Category"
+PROGRESS = "Progress"

+ 9 - 1
lang/it.ini

@@ -191,4 +191,12 @@ RADARR_PORT = "Radarr Port"
 RADARR_KEY = "Radarr API Key"
 MONTH = "Month"
 DAY = "Day"
-WEEK = "Week"
+WEEK = "Week"
+NZBGET_URL = "NZBGet URL"
+NZBGET_PORT = "NZBGet Port"
+QUEUE = "Queue"
+HISTORY = "History"
+FILE = "File"
+STATUS = "Status"
+CATEGORY = "Category"
+PROGRESS = "Progress"

+ 9 - 1
lang/nl.ini

@@ -191,4 +191,12 @@ RADARR_PORT = "Radarr Port"
 RADARR_KEY = "Radarr API Key"
 MONTH = "Month"
 DAY = "Day"
-WEEK = "Week"
+WEEK = "Week"
+NZBGET_URL = "NZBGet URL"
+NZBGET_PORT = "NZBGet Port"
+QUEUE = "Queue"
+HISTORY = "History"
+FILE = "File"
+STATUS = "Status"
+CATEGORY = "Category"
+PROGRESS = "Progress"

+ 9 - 1
lang/pl.ini

@@ -191,4 +191,12 @@ RADARR_PORT = "Radarr Port"
 RADARR_KEY = "Radarr API Key"
 MONTH = "Month"
 DAY = "Day"
-WEEK = "Week"
+WEEK = "Week"
+NZBGET_URL = "NZBGet URL"
+NZBGET_PORT = "NZBGet Port"
+QUEUE = "Queue"
+HISTORY = "History"
+FILE = "File"
+STATUS = "Status"
+CATEGORY = "Category"
+PROGRESS = "Progress"

+ 56 - 8
settings.php

@@ -635,7 +635,17 @@ endif;
                 position:absolute; display:none; z-index:99; 
             }.chooseTheme a:hover span { 
                 display:block; 
-            }<?php if(CUSTOMCSS == "true") : 
+            }ul.nav.nav-tabs.apps {
+                border: solid;
+                border-top: 0;
+                border-left: 0;
+                border-right: 0;
+                border-radius: 0;
+            }li.apps.active {
+                border: solid;
+                border-bottom: 0;
+                border-radius: 5px;
+}<?php if(CUSTOMCSS == "true") : 
 $template_file = "custom.css";
 $file_handle = fopen($template_file, "rb");
 echo fread($file_handle, filesize($template_file));
@@ -1300,23 +1310,29 @@ endif; ?>
                                                                                                     
                                                     <input type="hidden" name="action" value="homepageSettings" />
                                                 
-                                                    <ul class="nav nav-tabs">
+                                                    <ul class="nav nav-tabs apps">
 
-                                                        <li class="active">
+                                                        <li class="apps active">
 
-                                                            <a href="#tab-plex" data-toggle="tab" aria-expanded="true"><img style="height:20px; width:20px;" src="images/plex.png"></a>
+                                                            <a href="#tab-plex" data-toggle="tab" aria-expanded="true"><img style="height:40px; width:40px;" src="images/plex.png"></a>
 
                                                         </li>
 
-                                                        <li class="">
+                                                        <li class="apps ">
 
-                                                            <a href="#tab-sonarr" data-toggle="tab" aria-expanded="false"><img style="height:20px; width:20px;" src="images/sonarr.png"></a>
+                                                            <a href="#tab-sonarr" data-toggle="tab" aria-expanded="false"><img style="height:40px; width:40px;" src="images/sonarr.png"></a>
 
                                                         </li>
 
-                                                        <li class="">
+                                                        <li class="apps ">
 
-                                                            <a href="#tab-radarr" data-toggle="tab" aria-expanded="false"><img style="height:20px; width:20px;" src="images/radarr.png"></a>
+                                                            <a href="#tab-radarr" data-toggle="tab" aria-expanded="false"><img style="height:40px; width:40px;" src="images/radarr.png"></a>
+
+                                                        </li>
+                                                        
+                                                        <li class="apps ">
+
+                                                            <a href="#tab-nzbget" data-toggle="tab" aria-expanded="false"><img style="height:40px; width:40px;" src="images/nzbget.png"></a>
 
                                                         </li>
 
@@ -1440,6 +1456,38 @@ endif; ?>
                                                             </div>
 
                                                         </div>
+                                                        
+                                                        <div class="tab-pane big-box fade" id="tab-nzbget">
+
+                                                            <div class="form-group">
+
+                                                                <input type="text" class="form-control material input-sm" name="nzbgetURL" placeholder="<?php echo $language->translate("NZBGET_URL");?>" autocorrect="off" autocapitalize="off" value="<?php echo NZBGETURL;?>">
+                                                                <p class="help-text"><?php echo $language->translate("NZBGET_URL");?></p>
+
+                                                            </div>
+
+                                                            <div class="form-group">
+
+                                                                <input type="text" class="form-control material input-sm" name="nzbgetPort" placeholder="<?php echo $language->translate("NZBGET_PORT");?>" autocorrect="off" autocapitalize="off" value="<?php echo NZBGETPORT;?>">
+                                                                <p class="help-text"><?php echo $language->translate("NZBGET_PORT");?></p>
+
+                                                            </div>
+
+                                                            <div class="form-group">
+
+                                                                <input type="text" class="form-control material input-sm" name="nzbgetUsername" placeholder="<?php echo $language->translate("USERNAME");?>" autocorrect="off" autocapitalize="off" value="<?php echo NZBGETUSERNAME;?>">
+                                                                <p class="help-text"><?php echo $language->translate("USERNAME");?></p>
+
+                                                            </div>
+                                                            
+                                                            <div class="form-group">
+
+                                                                <input type="password" class="form-control material input-sm" name="nzbgetPassword" placeholder="<?php echo $language->translate("PASSWORD");?>" autocorrect="off" autocapitalize="off" value="<?php echo NZBGETPASSWORD;?>">
+                                                                <p class="help-text"><?php echo $language->translate("PASSWORD");?></p>
+
+                                                            </div>
+
+                                                        </div>
 
                                                     </div>
    

+ 5 - 1
user.php

@@ -8,7 +8,7 @@
 	 * salting subsequent password checks.
 	 */
     
-    define('INSTALLEDVERSION', '1.15');
+    define('INSTALLEDVERSION', '1.18');
 
     $databaseConfig = parse_ini_file('databaseLocation.ini.php', true);
     define('USER_HOME', $databaseConfig['databaseLocation'] . '/users/');
@@ -41,6 +41,10 @@
     if(!empty($homepageConfig['radarrKey'])) : define('RADARRKEY', $homepageConfig['radarrKey']); else : define('RADARRKEY', ''); endif;
     if(!empty($homepageConfig['radarrURL'])) : define('RADARRURL', $homepageConfig['radarrURL']); else : define('RADARRURL', ''); endif;
     if(!empty($homepageConfig['radarrPort'])) : define('RADARRPORT', $homepageConfig['radarrPort']); else : define('RADARRPORT', ''); endif;
+    if(!empty($homepageConfig['nzbgetURL'])) : define('NZBGETURL', $homepageConfig['nzbgetURL']); else : define('NZBGETURL', ''); endif;
+    if(!empty($homepageConfig['nzbgetPort'])) : define('NZBGETPORT', $homepageConfig['nzbgetPort']); else : define('NZBGETPORT', ''); endif;
+    if(!empty($homepageConfig['nzbgetUsername'])) : define('NZBGETUSERNAME', $homepageConfig['nzbgetUsername']); else : define('NZBGETUSERNAME', ''); endif;
+    if(!empty($homepageConfig['nzbgetPassword'])) : define('NZBGETPASSWORD', $homepageConfig['nzbgetPassword']); else : define('NZBGETPASSWORD', ''); endif;
 
     
     if(file_exists('custom.css')) : define('CUSTOMCSS', 'true'); else : define('CUSTOMCSS', 'false'); endif;