function parseEPGDataXMLTVTVGuide($providerId) { global $config, $programsXML, $system_timezone; $response = getEPGDataXMLTV($providerId); $start_time = strtotime($_GET['from_day']); $end_time = strtotime("+" . $_GET['DaysRequested'] . "days", $start_time); //$_GET['from_day'] $programsXML = ''; $programIds = array(); $i = 1; foreach ($response->channel as $channel) { $source_id = (strpos($channel['id'], '.') !== FALSE ? '99' : '') . str_replace('.', '', $channel['id']); $programsXML .= ' <source> <source_ID>' . $source_id . '</source_ID> <guide>' . "\n"; foreach ($response->programme as $program) { if ((string) $program['channel'] != (string) $channel['id']) { continue; } $start = (string) $program['start']; $end = (string) $program['stop']; $program_start_time = substr($start, 0, 4) . '-' . substr($start, 4, 2) . '-' . substr($start, 6, 2) . ' ' . substr($start, 8, 2) . ':' . substr($start, 10, 2); $program_start_time = strtotime("{$program_start_time} {$system_timezone}"); if ($program_start_time < $start_time || $program_start_time >= $end_time) { continue; } unset($category); $runtime = startstopToRuntime($start, $end) * 60; if (!empty($program->category)) { $category = (string) $program->category[0]; } $program->title = win2ascii($program->title); if (isset($program->{'sub-title'})) { $program->{'sub-title'} = win2ascii($program->{'sub-title'}); } $hash = getProgramHash($program); if (!isset($programIds[$hash])) { $programIds[$hash] = $i++; } $programsXML .= ' <program> <start_date>' . date('Ymd', $program_start_time) . '</start_date> <start_time>' . date('Hi', $program_start_time) . '</start_time> <duration>' . $runtime . '</duration> <program_ID>' . $programIds[$hash] . '</program_ID> <tv_rating>None</tv_rating> <tv_advisory>None</tv_advisory> <program_showing_type>None</program_showing_type> <audio_level_name>' . (@$program->hd ? 'Dolby 5.1' : 'Stereo') . '</audio_level_name> <closed_captioned>Y</closed_captioned> <program_airing_type>None</program_airing_type> <program_color_type>Color</program_color_type> <joined_in_progress>N</joined_in_progress> <letter_box>N</letter_box> <black_white>N</black_white> <continued>N</continued> <hdtv_level>' . (@$program->hd ? '1080i' : 'None') . '</hdtv_level> <subtitled>N</subtitled> <genre>' . (@$category == 'Sports' ? 'sports' : (@$category == 'News' ? 'newscast' : getSerieGenre($program->title))) . '</genre> <show_type>' . (isProgramSeries($program) ? 'EP' : (@$category == 'Movies' ? 'MV' : (@$category == 'Sports' ? 'SP' : 'SM'))) . '</show_type> <grid_title>' . xmlize(substr($program->title, 0, 15)) . '</grid_title> <short_title>' . xmlize(substr($program->title, 0, 30)) . '</short_title> <short_grid_title>' . xmlize(substr($program->title, 0, 8)) . '</short_grid_title> <medium_title>' . xmlize(substr($program->title, 0, 50)) . '</medium_title> <long_title>' . xmlize($program->title) . '</long_title> ' . (isset($program->{'sub-title'}) ? '<episode_title>' . xmlize($program->{'sub-title'}) . '</episode_title>' . "\n\t\t\t\t" : '') . '<half_stars_rating>0</half_stars_rating> <release_year>0</release_year> <mpaa_rating_reason /> <audio_level>' . (@$program->hd ? 'Dolby 5.1' : 'Stereo') . '</audio_level> </program>' . "\n"; } $programsXML .= ' </guide> </source>' . "\n"; } }
echo "\t<ErrorCode>1</ErrorCode>\n"; echo "\t<ErrorDescription>Can't find provider with ID='{$providerId}' in config.inc.php</ErrorDescription>\n"; } else { if ($config['providers'][$providerId]['epg-source'] == 'sd') { echo "\t<ErrorCode>0</ErrorCode>\n"; echo "\t<ErrorDescription>OK</ErrorDescription>\n"; $response = getEPGData($providerId); $stations = $response->xtvd->stations->station; $lineups = $response->xtvd->lineups->lineup->map; $stationsXML = getStationsXML($stations, $lineups, $providerId); } else { if ($config['providers'][$providerId]['epg-source'] == 'xmltv') { echo "\t<ErrorCode>0</ErrorCode>\n"; echo "\t<ErrorDescription>OK</ErrorDescription>\n"; require_once 'functions-xmltv.inc.php'; $response = getEPGDataXMLTV($providerId); $stations = $response->channel; $stationsXML = getStationsXMLTV($stations, $providerId); } } } } ?> <StationCount><?php echo sizeof($stations); ?> </StationCount> <UsingCachedData><?php echo $usingCache; ?> </UsingCachedData>