Skip to content

Commit

Permalink
Merge pull request #172 from causefx/develop
Browse files Browse the repository at this point in the history
Added NZBGET to Homepage - Fix more bugs
  • Loading branch information
causefx authored Mar 23, 2017
2 parents 9285061 + e322531 commit b37c99d
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 31 deletions.
79 changes: 75 additions & 4 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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>';

}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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>';

Expand Down Expand Up @@ -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; }

}


?>
106 changes: 103 additions & 3 deletions homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,106 @@
<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
Expand Down Expand Up @@ -288,14 +387,15 @@
//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: [

Expand Down
12 changes: 4 additions & 8 deletions image.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@

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";

}
10 changes: 9 additions & 1 deletion lang/de.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 9 additions & 1 deletion lang/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 9 additions & 1 deletion lang/es.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 9 additions & 1 deletion lang/fr.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 9 additions & 1 deletion lang/it.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 9 additions & 1 deletion lang/nl.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 9 additions & 1 deletion lang/pl.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading

0 comments on commit b37c99d

Please sign in to comment.