Skip to content

Commit

Permalink
Merge pull request #233 from causefx/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
causefx authored Apr 6, 2017
2 parents b1b95c1 + 4938655 commit ffc5fe0
Show file tree
Hide file tree
Showing 14 changed files with 330 additions and 56 deletions.
147 changes: 137 additions & 10 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

function debug_out($variable, $die = false) {
$trace = debug_backtrace()[0];
echo '<pre style="background-color: #f2f2f2; border: 2px solid black; border-radius: 5px; padding: 5px; margin: 5px";>'.$trace['file'].':'.$trace['line']."\n\n".print_r($variable, true).'</pre>';
if ($die) { http_response_code(503); die(); }
}

function clean($strin) {
$strout = null;

Expand Down Expand Up @@ -227,6 +233,132 @@ function get_browser_name() {

}

function resolveEmbyItem($address, $token, $item) {
// Static Height
$height = 150;

// Get Item Details
$itemDetails = json_decode(file_get_contents($address.'/Items?Ids='.$item['Id'].'&Fields=Overview&api_key='.$token),true)['Items'][0];

switch ($item['Type']) {
case 'Episode':
$title = $item['SeriesName'].': '.$item['Name'].' (Season '.$item['ParentIndexNumber'].': Episode '.$item['IndexNumber'].')';
$imageId = $itemDetails['SeriesId'];
$width = 100;
$image = 'season';
break;
case 'Music':
$title = $item['Name'];
$imageId = $itemDetails['AlbumId'];
$width = 150;
$image = 'music';
break;
default:
$title = $item['Name'];
$imageId = $item['Id'];
$width = 100;
$image = 'movie';
}

// If No Overview
if (!isset($itemDetails['Overview'])) {
$itemDetails['Overview'] = '';
}

// Assemble Item And Cache Into Array
return '<div class="item"><a href="'.$address.'/web/itemdetails.html?id='.$item['Id'].'" target="_blank"><img alt="'.$item['Name'].'" class="carousel-image '.$image.'" src="image.php?source=emby&img='.$imageId.'&height='.$height.'&width='.$width.'"></a><div class="carousel-caption '.$image.'""><h4>'.$title.'</h4><small><em>'.$itemDetails['Overview'].'</em></small></div></div>';
}

function outputCarousel($header, $size, $type, $items) {
// If None Populate Empty Item
if (!count($items)) {
$items = array('<div class="item"><img alt="nada" class="carousel-image movie" src="images/nadaplaying.jpg"><div class="carousel-caption"><h4>Nothing To Show</h4><small><em>Get Some Stuff Going!</em></small></div></div>');
}

// Set First As Active
$items[0] = preg_replace('/^<div class="item ?">/','<div class="item active">', $items[0]);

// Add Buttons
$buttons = '';
if (count($items) > 1) {
$buttons = '
<a class="left carousel-control '.$type.'" href="#carousel-'.$type.'-emby" role="button" data-slide="prev"><span class="fa fa-chevron-left" aria-hidden="true"></span><span class="sr-only">Previous</span></a>
<a class="right carousel-control '.$type.'" href="#carousel-'.$type.'-emby" role="button" data-slide="next"><span class="fa fa-chevron-right" aria-hidden="true"></span><span class="sr-only">Next</span></a>';
}

return '
<div class="col-lg-'.$size.'">
<h5 class="text-center">'.$header.'</h5>
<div id="carousel-'.$type.'-emby" class="carousel slide box-shadow white-bg" data-ride="carousel"><div class="carousel-inner" role="listbox">
'.implode('',$items).'
</div>'.$buttons.'
</div></div>';
}

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");
Expand All @@ -243,13 +375,9 @@ function getPlexRecent($url, $port, $type, $token, $size, $header){

$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 = file_get_contents($address."/?X-Plex-Token=".$token);
$getServer = simplexml_load_string($getServer);

foreach($getServer AS $child) {

$gotServer = $child['machineIdentifier'];
}
$gotServer = $getServer['machineIdentifier'];

$i = 0;

Expand Down Expand Up @@ -541,8 +669,7 @@ function getSonarrCalendar($array){

$i++;
$seriesName = $child['series']['title'];
$episodeID = $child['series']['imdbId'];
if(!isset($episodeID)){ $episodeID = ""; }
$episodeID = $child['series']['tvdbId'];
$episodeName = htmlentities($child['title'], ENT_QUOTES);
if($child['episodeNumber'] == "1"){ $episodePremier = "true"; }else{ $episodePremier = "false"; }
$episodeAirDate = $child['airDateUtc'];
Expand All @@ -554,7 +681,7 @@ function getSonarrCalendar($array){
$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";
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";

}

Expand Down Expand Up @@ -781,4 +908,4 @@ function getHeadphonesCalendar($url, $port, $key, $list){
if ($i != 0){ return $gotCalendar; }

}
?>
?>
24 changes: 22 additions & 2 deletions homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,32 @@

</div>

<div id="embyRow" class="row">

<sort>3</sort>

<?php
$embySize = 0;
if(EMBYRECENTMOVIE == "true"){ $embySize++; }
if(EMBYRECENTTV == "true"){ $embySize++; }
if(EMBYRECENTMUSIC == "true"){ $embySize++; }
if(EMBYPLAYINGNOW == "true"){ $embySize++; }
if($embySize >= 4){ $embySize = 3; }elseif($embySize == 3){ $embySize = 4; }elseif($embySize == 2){ $embySize = 6; }elseif($embySize == 1){ $embySize = 12; }

if(EMBYRECENTMOVIE == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "movie", EMBYTOKEN, $embySize, $language->translate("MOVIES")); }
if(EMBYRECENTTV == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "season", EMBYTOKEN, $embySize, $language->translate("TV_SHOWS")); }
if(EMBYRECENTMUSIC == "true"){ echo getEmbyRecent(EMBYURL, EMBYPORT, "album", EMBYTOKEN, $embySize, $language->translate("MUSIC")); }
if(EMBYPLAYINGNOW == "true"){ echo getEmbyStreams(EMBYURL, EMBYPORT, EMBYTOKEN, $embySize, $language->translate("PLAYING_NOW_ON_EMBY")); }
?>

</div>

<?php if(SONARRURL != "" || RADARRURL != "" || HEADPHONESURL != "" || SICKRAGEURL != "") : ?>
<div id="calendarLegendRow" class="row" style="padding: 0 0 10px 0;">

<sort>1</sort>

<div class="col-lg-4 content-form form-inline">
<div class="col-lg-12 content-form form-inline">

<div class="form-group">

Expand Down Expand Up @@ -591,4 +611,4 @@ function localStorageSupport() {

</body>

</html>
</html>
68 changes: 41 additions & 27 deletions image.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,45 @@
$image_url = $_GET['img'];
$image_height = $_GET['height'];
$image_width = $_GET['width'];

$urlCheck = stripos(PLEXURL, "http");

if ($urlCheck === false) {

$plexAddress = "http://" . PLEXURL;

}else{

$plexAddress = PLEXURL;

}

if(PLEXPORT !== ""){ $plexAddress = $plexAddress . ":" . PLEXPORT; }

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');

readfile($image_src);

} else {

echo "Invalid Plex Request";

$image_source = $_GET['source'];

switch ($image_source) {
case 'emby':
$urlCheck = stripos(EMBYURL, "http");

if ($urlCheck === false) {
$embyAddress = "http://" . EMBYURL;
} else {
$embyAddress = EMBYURL;
}

if(EMBYPORT !== ""){ $embyAddress .= ":" . EMBYPORT; }

if(isset($image_url) && isset($image_height) && isset($image_width)) {
$image_src = $embyAddress . '/Items/'.$image_url.'/Images/Primary?maxHeight='.$image_height.'&maxWidth='.$image_width;
header('Content-type: image/jpeg');
readfile($image_src);
} else {
echo "Invalid Emby Request";
}
break;
default:
$urlCheck = stripos(PLEXURL, "http");

if ($urlCheck === false) {
$plexAddress = "http://" . PLEXURL;
} else {
$plexAddress = PLEXURL;
}

if(PLEXPORT !== ""){ $plexAddress = $plexAddress . ":" . PLEXPORT; }

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');
readfile($image_src);
} else {
echo "Invalid Plex Request";
}
break;
}
Binary file modified images/jackett.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$inactivetext = "#66D9EF";
$loading = "#66D9EF";
$hovertext = "#000000";
$loadingIcon = "images/organizr.png";
$loadingIcon = "images/organizr_logo_d.png";
$baseURL = "";
require_once("translate.php");
require_once("functions.php");
Expand Down
23 changes: 14 additions & 9 deletions lang/de.ini
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,21 @@ HEADPHONES_URL = "Headphones URL"
HEADPHONES_PORT = "Headphones Port"
HEADPHONES_KEY = "Headphones API Schlüssel"
COOKIE_DOMAIN = "Domain-Name für Cookie"
DAYS = "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday"
CALENDAR_START_DAY = "First Day"
CALENDAR_START_DATE = "# of Days Before"
CALENDAR_END_DATE = "# of Days After"
DAYS = "Sonntag|Montag|Dienstag|Mittwoch|Donnerstag|Freitag|Samstag"
CALENDAR_START_DAY = "Erster Tag"
CALENDAR_START_DATE = "# der Tage davor"
CALENDAR_END_DATE = "# der Tage danach"
SICK_URL = "SickRage/SickBeard URL"
SICK_KEY = "SickRage/SickBeard API Key"
SICK_KEY = "SickRage/SickBeard API Schlüssel"
SMTP_HOST = "SMTP Host"
SMTP_HOST_PORT = "SMTP Port"
SMTP_HOST_AUTH = "SMTP Auth"
SMTP_HOST_USERNAME = "SMTP Username"
SMTP_HOST_PASSWORD = "SMTP Password"
SMTP_HOST_SENDER_NAME = "SMTP Sender Name"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
SMTP_HOST_USERNAME = "SMTP Benutzername"
SMTP_HOST_PASSWORD = "SMTP Passwort"
SMTP_HOST_SENDER_NAME = "SMTP Absender"
SMTP_HOST_SENDER_EMAIL = "SMTP Absendeadresse"
EMBY_URL = "Emby URL"
EMBY_PORT = "Emby Port"
EMBY_TOKEN = "Emby Token"
PLAYING_NOW_ON_EMBY = "Playing Now on EMBY"
RECENTLY_ADDED_TO_EMBY = "Recently Added to EMBY"
7 changes: 6 additions & 1 deletion lang/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ SMTP_HOST_AUTH = "SMTP Auth"
SMTP_HOST_USERNAME = "SMTP Username"
SMTP_HOST_PASSWORD = "SMTP Password"
SMTP_HOST_SENDER_NAME = "SMTP Sender Name"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
EMBY_URL = "Emby URL"
EMBY_PORT = "Emby Port"
EMBY_TOKEN = "Emby Token"
PLAYING_NOW_ON_EMBY = "Playing Now on EMBY"
RECENTLY_ADDED_TO_EMBY = "Recently Added to EMBY"
7 changes: 6 additions & 1 deletion lang/es.ini
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ SMTP_HOST_AUTH = "SMTP Auth"
SMTP_HOST_USERNAME = "SMTP Username"
SMTP_HOST_PASSWORD = "SMTP Password"
SMTP_HOST_SENDER_NAME = "SMTP Sender Name"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
EMBY_URL = "Emby URL"
EMBY_PORT = "Emby Port"
EMBY_TOKEN = "Emby Token"
PLAYING_NOW_ON_EMBY = "Playing Now on EMBY"
RECENTLY_ADDED_TO_EMBY = "Recently Added to EMBY"
7 changes: 6 additions & 1 deletion lang/fr.ini
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ SMTP_HOST_AUTH = "SMTP Auth"
SMTP_HOST_USERNAME = "SMTP Username"
SMTP_HOST_PASSWORD = "SMTP Password"
SMTP_HOST_SENDER_NAME = "SMTP Sender Name"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
EMBY_URL = "Emby URL"
EMBY_PORT = "Emby Port"
EMBY_TOKEN = "Emby Token"
PLAYING_NOW_ON_EMBY = "Playing Now on EMBY"
RECENTLY_ADDED_TO_EMBY = "Recently Added to EMBY"
7 changes: 6 additions & 1 deletion lang/it.ini
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,9 @@ SMTP_HOST_AUTH = "SMTP Auth"
SMTP_HOST_USERNAME = "SMTP Username"
SMTP_HOST_PASSWORD = "SMTP Password"
SMTP_HOST_SENDER_NAME = "SMTP Sender Name"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
SMTP_HOST_SENDER_EMAIL = "SMTP Sender Email"
EMBY_URL = "Emby URL"
EMBY_PORT = "Emby Port"
EMBY_TOKEN = "Emby Token"
PLAYING_NOW_ON_EMBY = "Playing Now on EMBY"
RECENTLY_ADDED_TO_EMBY = "Recently Added to EMBY"
Loading

0 comments on commit ffc5fe0

Please sign in to comment.