(20\d\d) shows<\/b>/i',$line,$matches)) { $current_year = $matches[1]; } if($line_date = preg_match('/]*>(\d+\/\d+)<\/td>/i',$line,$matches)) { $line = str_replace($matches[1],($matches[1] . "/$current_year"),$line); } $archives_html .= $line; } $items = array(); $matches = array(); if(preg_match_all('/\s*]*>(.*?)<\/td>\s*]*>(.*?)<\/td>\s*]*>(.*?)<\/td>\s*]*>(.*?)<\/td>\s*<\/tr>/i',$archives_html,$matches,PREG_SET_ORDER)) { foreach($matches as $match) { $base_url = preg_replace('/\/[^\/]*$/','',ARCHIVE_PAGE_URL) . '/'; if(preg_match("/href=['\"](.*?)\.m3u['\"]/i",$match[1],$m3u_matches)) { $show_url = ''; if(preg_match("/href=['\"](.*?)['\"]/i",$match[4],$show_url_matches)) { $show_url = $show_url_matches[1]; } if(strlen($show_url)) { $show_url = $base_url . $show_url; while(strpos($show_url,"/../")) { $show_url = preg_replace('/\/[^\/]+\/\.\.\//','/',$show_url); } } $items[] = array( 'm3u' => ($m3u_matches[1] . '.m3u'), 'title' => strip_tags($match[4]), 'date' => $match[3], 'timestamp' => strtotime($match[3]), 'url' => $show_url ); } } usort($items,"usort_compare"); //print_r($items); $output = ' This American Life http://www.thislife.org en-us copright ' . date('Y') . ' Public Radio International Movies for radio Ira Glass et al. Each week we choose a theme and put together different kinds of stories on that theme. A documentary show for people who normally hate documentaries. A public radio show for people who dont necessarily care for public radio. '; $num_items_to_display = min(sizeof($items),NUMBER_EPISODES); $item_count = 0; $item_index = 0; while($item_count<$num_items_to_display) { $item = $items[$item_index]; while((!$mp3_url = GetMp3Url($item['m3u'])) && ($item_index=sizeof($items)) break; $headers = getFileHttpHeaders($mp3_url); $mp3_size = trim($headers['content-length']); $output .= ' ' . $item['title'] . ' WBEZ ' . $item['url'] . ' ' . $mp3_url . ' ' . date('r',$item['timestamp']) . ' '; $item_count++; $item_index++; if($item_index>=sizeof($items)) break; } $output .= ' '; print $output; } else { print 'bad regex'; } ?>