This php script will create a podcast XML on the fly listing all mp3 files in the same directory. */ $channeltitle = "Streamplan files"; $channelauthor = "Various"; /* $sortby sets the order in which tracks are listed. Options: "newest" = newest on top "oldest" = oldest on top "filedesc" = alphabetically descending "fileasc" = alphabetically ascending default: "filedesc" (== how streamplan.sh works) */ $sortby = "filedesc"; $dir = "http://".$_SERVER['SERVER_NAME']; $parts = explode('/',$_SERVER['REQUEST_URI']); for ($i = 0; $i < count($parts) - 1; $i++) { $dir .= $parts[$i] . "/"; } header('Content-type: text/xml', true); print" $channeltitle $dir $channelauthor "; /**/ // read all mp3 files in the directory $temp = glob("*.mp3"); // create array with timestamp.filename as key foreach ($temp as $filename) { $mp3files[filemtime($filename).$filename] = $filename; } // change the order of the list according to $sortby set above switch ($sortby) { case "newest": krsort($mp3files); break; case "oldest": ksort($mp3files); break; case "fileasc": natcasesort($mp3files); break; default: // filedesc natcasesort($mp3files); $mp3files = array_reverse($mp3files); break; } // go through files and create for podcast foreach ($mp3files as $filename) { // set empty array for metadata $iteminfo = array( "TPE1" => "", "TIT2" => "", "WOAF" => "", "Filename" => "" ); // read id3 from shell command $idtag = explode("\n",shell_exec("id3v2 -R $filename")); foreach($idtag as $line) { // to to match key => value from each line preg_match("/((\w+): (.*))/", $line, $results); // if ID3 tag found, results will return four values if(count($results) == 4) { $iteminfo[$results[2]] = $results[3]; } } // if title too short, use filename as title if (strlen($iteminfo['TIT2']) < 2) { $iteminfo['TIT2'] = $filename; } print " ".$iteminfo['TIT2']." ".$iteminfo['TPE1']." ".$iteminfo['WOAF']." ".$iteminfo['TIT2']." by ".$iteminfo['TPE1'].". ".$iteminfo['COMM']." Recorded on ".date ("r", filemtime($filename))." from stream URL: ".$iteminfo['WOAF']." ".$dir.$filename." ".date ("r", filemtime($filename))." "; } print" "; ?>