1<?php 2/** 3 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 4 * @author Andreas Gohr <gohr@cosmocode.de> 5 */ 6 7if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 8if(!defined('NL')) define('NL',"\n"); 9require_once(DOKU_INC.'inc/init.php'); 10require_once(DOKU_INC.'inc/auth.php'); 11session_write_close(); 12require_once(DOKU_INC.'inc/search.php'); 13require_once(dirname(__FILE__).'/id3/getid3.php'); 14 15// get namespace and check permission 16$ns = $_REQUEST['ns']; 17if(auth_quickaclcheck("$ns:*") < AUTH_READ){ 18 header("HTTP/1.0 401 Unauthorized"); 19 echo 'not authorized'; 20 exit; 21} 22 23if(!$ns){ 24 header("HTTP/1.0 400 Bad Request"); 25 echo 'bad request'; 26 exit; 27} 28 29 30// get a list of files 31$dir = utf8_encodeFN(str_replace(':','/',$ns)); 32$files = array(); 33search($files,$conf['mediadir'],'search_media',array(),$dir); 34 35$id3 = new getID3(); 36$id3->encoding = 'UTF-8'; 37$id3->option_tag_lyrics3 = false; 38$id3->option_tag_apetag = false; 39$id3->option_tags_html = false; 40$id3->option_extra_info = false; 41 42// output a list 43header('Content-Type: text/xml; charset=utf-8'); 44echo '<?xml version="1.0" encoding="UTF-8"?>'.NL; 45echo '<playlist version="0" xmlns="http://xspf.org/ns/0/">'.NL; 46echo ' <trackList>'.NL; 47foreach($files as $file){ 48 if(!preg_match('/\.(flv|mp3)$/',$file['id'])) continue; 49 50 $info = $id3->analyze(mediaFN($file['id'])); 51 getid3_lib::CopyTagsToComments($info); 52 53 echo ' <track>'.NL; 54 echo ' <location>'.ml($file['id']).'</location>'.NL; 55 56 if(isset($info['comments']['artist'][0])) 57 echo ' <creator>'.hsc($info['comments']['artist'][0]).'</creator>'.NL; 58 if(isset($info['comments']['title'][0])) 59 echo ' <title>'.hsc($info['comments']['title'][0]).'</title>'.NL; 60 if(isset($info['comments']['length'][0])) 61 echo ' <duration>'.hsc($info['comments']['length'][0]*1000).'</duration>'.NL; 62 if($info['fileformat'] == 'mp3') 63 echo ' <meta rel="http://geekkid.net/type">audio</meta>'.NL; 64 65 echo ' <annotation>'.hsc(noNS($file['id'])).'</annotation>'.NL; 66 echo ' </track>'.NL; 67} 68echo ' </trackList>'.NL; 69echo '</playlist>'.NL; 70 71 72 73 74//Setup VIM: ex: et ts=4 enc=utf-8 : 75