', $items[0]);
// Add Buttons
$buttons = '';
if (count($items) > 1) {
$buttons = '
Previous
Next';
}
return '
'.$header.'
'.implode('',$items).'
'.$buttons.'
';
}
function getEmbyStreams($url, $port, $token, $size, $header) {
if (stripos($url, "http") === false) {
$url = "http://" . $url;
}
if ($port !== "") {
$url = $url . ":" . $port;
}
$address = $url;
$api = json_decode(file_get_contents($address.'/Sessions?api_key='.$token),true);
$playingItems = array();
foreach($api as $key => $value) {
if (isset($value['NowPlayingItem'])) {
$playingItems[] = resolveEmbyItem($address, $token, $value['NowPlayingItem']);
}
}
return outputCarousel($header, $size, 'streams', $playingItems);
}
function getEmbyRecent($url, $port, $type, $token, $size, $header) {
if (stripos($url, "http") === false) {
$url = "http://" . $url;
}
if ($port !== "") {
$url = $url . ":" . $port;
}
$address = $url;
// Resolve Types
switch ($type) {
case 'movie':
$embyTypeQuery = 'IncludeItemTypes=Movie&';
break;
case 'season':
$embyTypeQuery = 'IncludeItemTypes=Episode&';
break;
case 'album':
$embyTypeQuery = 'IncludeItemTypes=Music&';
break;
default:
$embyTypeQuery = '';
}
// Get A User
$userId = json_decode(file_get_contents($address.'/Users?api_key='.$token),true)[0]['Id'];
// Get the latest Items
$latest = json_decode(file_get_contents($address.'/Users/'.$userId.'/Items/Latest?'.$embyTypeQuery.'EnableImages=false&api_key='.$token),true);
// For Each Item In Category
$items = array();
foreach ($latest as $k => $v) {
$items[] = resolveEmbyItem($address, $token, $v);
}
return outputCarousel($header, $size, $type, $items);
}
function getPlexRecent($url, $port, $type, $token, $size, $header){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$api = file_get_contents($address."/library/recentlyAdded?X-Plex-Token=".$token);
$api = simplexml_load_string($api);
$getServer = file_get_contents($address."/servers?X-Plex-Token=".$token);
$getServer = simplexml_load_string($getServer);
foreach($getServer AS $child) {
$gotServer = $child['machineIdentifier'];
}
$i = 0;
$gotPlex = '
'.$header.'
';
foreach($api AS $child) {
if($child['type'] == $type){
$i++;
if($i == 1){ $active = "active"; }else{ $active = "";}
$thumb = $child['thumb'];
$plexLink = "https://app.plex.tv/web/app#!/server/$gotServer/details?key=/library/metadata/".$child['ratingKey'];
if($type == "movie"){
$title = $child['title'];
$summary = $child['summary'];
$height = "150";
$width = "100";
}elseif($type == "season"){
$title = $child['parentTitle'];
$summary = $child['parentSummary'];
$height = "150";
$width = "100";
}elseif($type == "album"){
$title = $child['parentTitle'];
$summary = $child['title'];
$height = "150";
$width = "150";
}
$gotPlex .= '
'.$title.'
'.$summary.' ';
$plexLink = "";
}
}
$gotPlex .= '
';
if ($i > 1){
$gotPlex .= '
PreviousNext';
}
$gotPlex .= '
';
$noPlex = '
'.$header.'
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= "

";
$noPlex .= '
Nothing New
Get to Adding! ';
if ($i != 0){ return $gotPlex; }
if ($i == 0){ return $noPlex; }
}
function getPlexStreams($url, $port, $token, $size, $header){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$api = file_get_contents($address."/status/sessions?X-Plex-Token=".$token);
$api = simplexml_load_string($api);
$getServer = file_get_contents($address."/servers?X-Plex-Token=".$token);
$getServer = simplexml_load_string($getServer);
foreach($getServer AS $child) {
$gotServer = $child['machineIdentifier'];
}
$i = 0;
$gotPlex = '
'.$header.'
';
$gotPlex .= '
';
$gotPlex .= '
';
foreach($api AS $child) {
$type = $child['type'];
$plexLink = "https://app.plex.tv/web/app#!/server/$gotServer/details?key=/library/metadata/".$child['ratingKey'];
$i++;
if($i == 1){ $active = "active"; }else{ $active = "";}
if($type == "movie"){
$title = $child['title'];
$summary = htmlentities($child['summary'], ENT_QUOTES);
$thumb = $child['thumb'];
$image = "movie";
$height = "150";
$width = "100";
}elseif($type == "episode"){
$title = $child['grandparentTitle'];
$summary = htmlentities($child['summary'], ENT_QUOTES);
$thumb = $child['grandparentThumb'];
$image = "season";
$height = "150";
$width = "100";
}elseif($type == "track"){
$title = $child['grandparentTitle'] . " - " . $child['parentTitle'];
$summary = htmlentities($child['title'], ENT_QUOTES);
$thumb = $child['thumb'];
$image = "album";
$height = "150";
$width = "150";
}elseif($type == "clip"){
$title = $child['title'].' - Trailer';
$summary = ($child['summary'] != "" ? $child['summary'] : "
No summary loaded.");
$thumb = ($child['thumb'] != "" ? $child['thumb'] : 'images/nadaplaying.jpg');
$image = "movie";
$height = "150";
$width = "100";
}
$gotPlex .= '
';
$gotPlex .= "

";
$gotPlex .= '
'.$title.'
'.$summary.'';
$plexLink = "";
}
$gotPlex .= '
';
if ($i > 1){
$gotPlex .= '
PreviousNext';
}
$gotPlex .= '
';
$noPlex = '
'.$header.'
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= '
';
$noPlex .= "

";
$noPlex .= '
Nothing Playing
Get to Streaming!';
if ($i != 0){ return $gotPlex; }
if ($i == 0){ return $noPlex; }
}
function getSickrageCalendarWanted($array){
$array = json_decode($array, true);
$gotCalendar = "";
$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 = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
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 = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
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 = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
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 = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
if ($i != 0){ return $gotCalendar; }
}
function getSickrageCalendarHistory($array){
$array = json_decode($array, true);
$gotCalendar = "";
$i = 0;
foreach($array['data'] AS $child) {
$i++;
$seriesName = $child['show_name'];
$episodeID = $child['tvdbid'];
$episodeAirDate = $child['date'];
$downloaded = "green-bg";
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";
}
if ($i != 0){ return $gotCalendar; }
}
function getSonarrCalendar($array){
$array = json_decode($array, true);
$gotCalendar = "";
$i = 0;
foreach($array AS $child) {
$i++;
$seriesName = $child['series']['title'];
$episodeID = $child['series']['imdbId'];
if(!isset($episodeID)){ $episodeID = ""; }
$episodeName = htmlentities($child['title'], ENT_QUOTES);
if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
$episodeAirDate = $child['airDateUtc'];
$episodeAirDate = strtotime($episodeAirDate);
$episodeAirDate = date("Y-m-d H:i:s", $episodeAirDate);
if (new DateTime() < new DateTime($episodeAirDate)) { $unaired = true; }
$downloaded = $child['hasFile'];
if($downloaded == "0" && isset($unaired) && $episodePremier == "true"){ $downloaded = "light-blue-bg"; }elseif($downloaded == "0" && isset($unaired)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"http://www.imdb.com/title/$episodeID\" }, \n";
}
if ($i != 0){ return $gotCalendar; }
}
function getRadarrCalendar($array){
$array = json_decode($array, true);
$gotCalendar = "";
$i = 0;
foreach($array AS $child) {
if(isset($child['inCinemas'])){
$i++;
$movieName = $child['title'];
$movieID = $child['imdbId'];
if(!isset($movieID)){ $movieID = ""; }
if(isset($child['inCinemas']) && isset($child['physicalRelease'])){
$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 = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
}else{
$physicalRelease = $child['inCinemas'];
$downloaded = "light-blue-bg";
}
$gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded\", imagetype: \"film\", url: \"http://www.imdb.com/title/$movieID\" }, \n";
}
}
if ($i != 0){ return $gotCalendar; }
}
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 '
' . var_export($child, true) . '
';
$downloadName = htmlentities($child['NZBName'], ENT_QUOTES);
$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 .= '
| '.$downloadName.' |
'.$downloadStatus.' |
'.$downloadCategory.' |
'.round($downloadPercent).'%
'.$downloadPercent.'% Complete
|
';
}
if($i > 0){ return $gotNZB; }
if($i == 0){ echo '
No Results |
'; }
}
function sabnzbdConnect($url, $port, $key, $list){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$api = file_get_contents("$url/api?mode=$list&output=json&apikey=$key");
$api = json_decode($api, true);
$i = 0;
$gotNZB = "";
foreach ($api[$list]['slots'] AS $child) {
$i++;
if($list == "queue"){ $downloadName = $child['filename']; $downloadCategory = $child['cat']; $downloadPercent = (($child['mb'] - $child['mbleft']) / $child['mb']) * 100; $progressBar = "progress-bar-striped active"; }
if($list == "history"){ $downloadName = $child['name']; $downloadCategory = $child['category']; $downloadPercent = "100"; $progressBar = ""; }
$downloadStatus = $child['status'];
$gotNZB .= '
| '.$downloadName.' |
'.$downloadStatus.' |
'.$downloadCategory.' |
'.round($downloadPercent).'%
'.$downloadPercent.'% Complete
|
';
}
if($i > 0){ return $gotNZB; }
if($i == 0){ echo '
No Results |
'; }
}
function getHeadphonesCalendar($url, $port, $key, $list){
$urlCheck = stripos($url, "http");
if ($urlCheck === false) {
$url = "http://" . $url;
}
if($port !== ""){ $url = $url . ":" . $port; }
$address = $url;
$api = file_get_contents($address."/api?apikey=".$key."&cmd=$list");
$api = json_decode($api, true);
$i = 0;
$gotCalendar = "";
foreach($api AS $child) {
if($child['Status'] == "Wanted"){
$i++;
$albumName = addslashes($child['AlbumTitle']);
$albumArtist = htmlentities($child['ArtistName'], ENT_QUOTES);
$albumDate = $child['ReleaseDate'];
$albumID = $child['AlbumID'];
$albumDate = strtotime($albumDate);
$albumDate = date("Y-m-d", $albumDate);
$albumStatus = $child['Status'];
if (new DateTime() < new DateTime($albumDate)) { $notReleased = "true"; }else{ $notReleased = "false"; }
if($albumStatus == "Wanted" && $notReleased == "true"){ $albumStatusColor = "indigo-bg"; }elseif($albumStatus == "Downloaded"){ $albumStatusColor = "green-bg"; }else{ $albumStatusColor = "red-bg"; }
$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";
}
}
if ($i != 0){ return $gotCalendar; }
}
?>