"; $top_line = "

"; $middle_line = "

"; $bottom_line = "

"; $side_channel = "

Channel $channel_num

"; $position_half = ""; } if ($DisplayType == 'full') { foreach ($xml->Video as $playdata) { if($playdata->Player['title'] == $plexClientName) { $video_duration = (int)$playdata['duration']; if($playdata['type'] == "movie") { if ($video_duration < "1800000") { //COMMERCIAL $text_color='cyan'; $text_color_alt='cyan'; } else { //MOVIE $text_color='yellow'; $text_color_alt='white'; } } elseif($playdata['type'] == "show" || $playdata['parentTitle'] != "") { //TV SHOW $text_color='yellow'; $text_color_alt='white'; } else { $text_color='cyan'; $text_color_alt='cyan'; } } } # SET FULL OPTIONS $time_style = "

"; $top_line = "

"; $middle_line = "

"; $bottom_line = "

"; $side_channel = "

Channel $channel_num

"; $position_play_full = ""; $position_idle_full = ""; } if(strcmp($channel_num," ")<=0){ $channel_num=0; } //If Nothing is Playing $text_color='cyan'; $text_color_alt='cyan'; if ($DisplayType == 'full') { $position=$position_idle_full; } if ($DisplayType == 'half') { $position=$position_half; } if ($pgrep >= 1) { //PSEUDO CHANNEL ON $top_section = $time_style . $date . "

" . $position; $middle_section = $top_line . "Channel $channel_num

"; $bottom_section = $middle_line . "

"; $nowplaying = "Channel $channel_num Standing By..."; } else { //PSEUDO CHANNEL OFF $top_section = $time_style . $date . "

" . $position; $middle_section = $top_line . $day . "

"; $bottom_section = "

"; $nowplaying = "Please Stand By..."; } if ($xml['size'] != '0') { //IF PLAYING CONTENT foreach ($xml->Video as $clients) { if($clients->Player['title'] == $plexClientName) { //If the active client on plex matches the client in the config //IF PLAYING COMMERCIAL if($clients['type'] == "movie" && $clients['duration'] < 1800000) { #$text_color='cyan'; #$text_color_alt='cyan'; if ($DisplayType == 'full') { $position=$position_idle_full; } if ($DisplayType == 'half') { $position=$position_half; } $top_section = $time_style . $date . "

" . $position; $middle_section = $top_line . $clients['librarySectionTitle'] . "

"; $bottom_section = "

"; $title_clean = str_replace("_", " ", $clients['title']); $nowplaying = "Now Playing: " . $title_clean . " on Channel ". $channel_num . ""; } //IF PLAYING MOVIE if($clients['type'] == "movie" && $clients['duration'] >= 1800000) { $text_color='yellow'; $text_color_alt='white'; if ($DisplayType == 'half') { $art = $clients['thumb']; $background_art = ""; $position=$position_half; } if ($DisplayType == 'full') { $art = $clients['art']; $background_art = ""; $position=$position_play_full; } $top_section = $background_art . $time_style . $date . $side_channel . "

" . $position; $middle_section = $top_line . $clients['title'] . $middle_line . $clients['year'] . "

"; $bottom_section = $bottom_line . $clients['tagline'] . "

"; $nowplaying = "Now Playing: " . $clients['title'] . " (" . $clients['year'] . ")" . " on Channel ". $channel_num . ""; } //IF PLAYING TV SHOW if($clients['type'] == "show" || $clients['parentTitle'] != "") { if ($DisplayType == 'half') { $art = $clients['parentThumb']; $background_art = ""; $position=$position_half; } if ($DisplayType == 'full') { $art = $clients['grandparentArt']; $background_art = ""; $position=$position_play_full; $text_color='yellow'; $text_color_alt='white'; } $top_section = $background_art . $time_style . $date . "

" . $position; $middle_section = $top_line . $clients['grandparentTitle'] . "

" . $middle_line . $clients['parentTitle'] . ", Episode " . $clients['index'] . "

"; $bottom_section = $bottom_line . $clients['title'] . "

" . $side_channel . "

"; $nowplaying = "Now Playing: " . $clients['grandparentTitle'] . " • " . $clients['parentTitle'] . ", Episode " . $clients['index'] . " • " . $clients['title'] . " on Channel ". $channel_num . ""; } } } } //BUILD DAILY SCHEDULE PAGES $doheader = "0"; foreach ($dircontents as $xmlfile) { //do the following for each xml schedule file $xmldata = simplexml_load_file($xmlfile); //load the xml schedule file foreach($xmldata->time as $attributes) { //for each entry in the schedule, do the following $start_time_unix = strtotime($attributes['time-start']); //get the entry start time $start_time_human = date("H:i", $start_time_unix); //convert start time to readable format $duration_seconds = $attributes['duration']/1000; //get entry duration and convert to seconds $duration_seconds = $duration_seconds-1; $end_time_unix = $start_time_unix + $duration_seconds; //using start time and duration, calculate the end time $end_time_human = date("H:i", $end_time_unix); //end time in readable format $ch_file = str_replace($pseudochannelMaster . "pseudo-channel_", "ch", $xmlfile); //get channel number $ch_file = str_replace("/schedules/pseudo_schedule.xml", "", $ch_file); $ch_number = str_replace("ch", "", $ch_file); if ($doheader != "1") { $tableheader = ""; $chantableheader = "
 Channel TimeTitle
"; $nowtable .= ""; $nowtable .= ""; } elseif ($attributes['type'] == "Commercials") { $nowtable .= $attributes['type'] . ""; } else { $nowtable .= $attributes['title'] . ""; } } if ($results[$ch_file] == "") { $results[$ch_file] = $chantableheader . "Channel " . $ch_number . ""; } if ($rightnow >= $start_time_unix && $rightnow < $end_time_unix) { $isnowplaying = "font-weight:bold;font-size:1.2em"; } else { $isnowplaying = ""; } if ($attributes['type'] != "Commercials") { $results[$ch_file] .= ""; $results[$ch_file] .= ""; $results[$ch_file] .= ""; } elseif ($attributes['type'] == "Commercials") { $results[$ch_file] .= $attributes['type'] . ""; } else { $results[$ch_file] .= $attributes['title'] . ""; } } } } $nowtable .= "
"; $nowtable = $tableheader; $doheader = "1"; } if ($chnum == $ch_number) { $channelplaying = "font-weight:bold;font-size:1.1em"; } else { $channelplaying = ""; } if ($rightnow >= $start_time_unix && $rightnow <= $end_time_unix) { $nowtable .= "
" . $ch_number . "" . $start_time_human . " - " . $end_time_human . "  "; if ($attributes['type'] == "TV Shows") { $nowtable .= $attributes['show-title']; $nowtable .= "
 S" . $attributes['show-season'] . "E" . $attributes['show-episode'] . " - " . $attributes['title'] . "
TimeTitle
" . $start_time_human . " - " . $end_time_human . "  "; if ($attributes['type'] == "TV Shows") { $results[$ch_file] .= $attributes['show-title']; $results[$ch_file] .= "
 S" . $attributes['show-season'] . "E" . $attributes['show-episode'] . " - " . $attributes['title'] . "
"; $results[$ch_file] .= ""; $results['rightnow'] = $nowtable; $results['top'] = "$top_section"; $results['middle'] = "$middle_section $bottom_section"; $results['bottom'] = "

"; $results['nowplaying'] = "$nowplaying"; echo json_encode($results); ?>