Skip to content

Commit

Permalink
Merge pull request #221 from causefx/develop
Browse files Browse the repository at this point in the history
Settings Change and fixes
  • Loading branch information
causefx authored Apr 1, 2017
2 parents 7215ce7 + 7d4dffd commit 8de5579
Show file tree
Hide file tree
Showing 5 changed files with 1,411 additions and 1,032 deletions.
2 changes: 1 addition & 1 deletion downloader.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$auth = strpos($_SERVER[HTTP_REFERER], "homepage.php");
$auth = strpos($_SERVER['HTTP_REFERER'], "homepage.php");

if ($auth === false) { die("WTF? Bro!"); }

Expand Down
59 changes: 40 additions & 19 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ function getSickrageCalendarWanted($array){

$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]));
Expand All @@ -452,14 +453,15 @@ function getSickrageCalendarWanted($array){
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\" }, \n";
$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]));
Expand All @@ -468,14 +470,15 @@ function getSickrageCalendarWanted($array){
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\" }, \n";
$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]));
Expand All @@ -484,14 +487,15 @@ function getSickrageCalendarWanted($array){
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\" }, \n";
$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]));
Expand All @@ -500,7 +504,7 @@ function getSickrageCalendarWanted($array){
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\" }, \n";
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";

}

Expand All @@ -518,9 +522,10 @@ function getSickrageCalendarHistory($array){

$i++;
$seriesName = $child['show_name'];
$episodeID = $child['tvdbid'];
$episodeAirDate = $child['date'];
$downloaded = "green-bg";
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\" }, \n";
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"https://thetvdb.com/?tab=series&id=$episodeID\" }, \n";

}

Expand All @@ -536,19 +541,21 @@ function getSonarrCalendar($array){
foreach($array AS $child) {

$i++;
$seriesName = htmlentities($child['series']['title'], ENT_QUOTES);
$seriesName = $child['series']['title'];
$runtime = $child['series']['runtime'];
$episodeID = $child['series']['imdbId'];
$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)){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg";}else{ $downloaded = "red-bg"; }
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\" }, \n";
$gotCalendar .= "{ title: \"$seriesName\", start: \"$episodeAirDate\", className: \"$downloaded\", imagetype: \"tv\", url: \"http://www.imdb.com/title/$episodeID\" }, \n";

}

Expand All @@ -562,20 +569,33 @@ function getRadarrCalendar($array){
$gotCalendar = "";
$i = 0;
foreach($array AS $child) {
if(isset($child['physicalRelease'])){

if(isset($child['inCinemas'])){

$i++;
$movieName = htmlentities($child['title'], ENT_QUOTES);
$movieName = $child['title'];
$movieID = $child['imdbId'];
$runtime = $child['runtime'];
$physicalRelease = $child['physicalRelease'];
$physicalRelease = strtotime($physicalRelease);
$physicalRelease = date("Y-m-d", $physicalRelease);

if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
if(isset($child['inCinemas']) && isset($child['physicalRelease'])){

$physicalRelease = $child['physicalRelease'];
$physicalRelease = strtotime($physicalRelease);
$physicalRelease = date("Y-m-d", $physicalRelease);

$downloaded = $child['hasFile'];
if($downloaded == "0" && $notReleased == "true"){ $downloaded = "indigo-bg"; }elseif($downloaded == "1"){ $downloaded = "green-bg"; }else{ $downloaded = "red-bg"; }
if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }

$gotCalendar .= "{ title: \"$movieName\", start: \"$physicalRelease\", className: \"$downloaded\", imagetype: \"film\" }, \n";
$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";
}

}
Expand Down Expand Up @@ -738,12 +758,13 @@ function getHeadphonesCalendar($url, $port, $key, $list){

foreach($api AS $child) {

if($child['Status'] != "Skipped"){
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'];
Expand All @@ -752,7 +773,7 @@ function getHeadphonesCalendar($url, $port, $key, $list){

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\" }, \n";
$gotCalendar .= "{ title: \"$albumArtist - $albumName\", start: \"$albumDate\", className: \"$albumStatusColor\", imagetype: \"music\", url: \"https://musicbrainz.org/release-group/$albumID\" }, \n";

}

Expand Down
23 changes: 21 additions & 2 deletions homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
<![endif]-->

<style>
sort {
display: none;
}
table.fc-list-table {
table-layout: auto;
}.tabbable{
Expand Down Expand Up @@ -190,10 +193,11 @@
<div class="main-wrapper" style="position: initial;">

<div id="content" class="container-fluid">

<!-- <button id="numBnt">Numerical</button> -->
<br/>
<?php if(($USER->authenticated && $USER->role == "admin") && (NZBGETURL != "" || SABNZBDURL != "" )) : ?>
<div id="downloadClientRow" class="row">
<sort>2</sort>

<div class="col-xs-12 col-md-12">

Expand Down Expand Up @@ -318,6 +322,8 @@
<?php endif; ?>

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

<sort>3</sort>

<?php
$plexSize = 0;
Expand All @@ -338,6 +344,8 @@
<?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="form-group">
Expand All @@ -354,6 +362,7 @@
<span class="label label-primary well-sm">Available</span>
<span class="label label-danger well-sm">Unavailable</span>
<span class="label indigo-bg well-sm">Unreleased</span>
<span class="label light-blue-bg well-sm">Premier</span>

</div>

Expand All @@ -362,6 +371,8 @@
</div>

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

<sort>1</sort>

<div class="col-lg-12">

Expand Down Expand Up @@ -548,7 +559,7 @@ function localStorageSupport() {
<?php if(SICKRAGEURL != ""){ echo getSickrageCalendarWanted($sickrage->future()); echo getSickrageCalendarHistory($sickrage->history("100","downloaded")); } ?>
<?php if(SONARRURL != ""){ echo getSonarrCalendar($sonarr->getCalendar($startDate, $endDate)); } ?>
<?php if(RADARRURL != ""){ echo getRadarrCalendar($radarr->getCalendar($startDate, $endDate)); } ?>
<?php if(HEADPHONESURL != ""){ echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getUpcoming"); echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getWanted"); } ?>
<?php if(HEADPHONESURL != ""){ echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getHistory"); echo getHeadphonesCalendar(HEADPHONESURL, HEADPHONESPORT, HEADPHONESKEY, "getWanted"); } ?>
],

eventRender: function eventRender( event, element, view ) {
Expand All @@ -565,7 +576,15 @@ function localStorageSupport() {
$('#imagetype_selector').on('change',function(){
$('#calendar').fullCalendar('rerenderEvents');
})

var $divs = $("div.row");

$('#numBnt').on('click', function () {
var numericallyOrderedDivs = $divs.sort(function (a, b) {
return $(a).find("sort").text() > $(b).find("sort").text();
});
$("#content").html(numericallyOrderedDivs);
});

</script>
<?php endif; ?>
Expand Down
Loading

0 comments on commit 8de5579

Please sign in to comment.