2011-07-22 08:30:52 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ownCloud - media plugin
|
|
|
|
*
|
|
|
|
* @author Robin Appelman
|
|
|
|
* @copyright 2010 Robin Appelman icewind1991@gmail.com
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
//implementation of ampache's xml api
|
|
|
|
class OC_MEDIA_AMPACHE{
|
|
|
|
|
2012-01-24 05:56:38 +04:00
|
|
|
/**
|
|
|
|
* fix the string to be XML compatible
|
|
|
|
* @param string name
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* this is an ugly hack(tm), this should be: */
|
|
|
|
/* htmlentities($name, ENT_XML1, 'UTF-8'); */
|
|
|
|
/* with PHP 5.4 and later */
|
|
|
|
public static function fixXmlString($name){
|
|
|
|
$result=str_replace("&", "&", $name);
|
|
|
|
$result=str_replace("'", "'", $result);
|
|
|
|
$result=str_replace("<", "<", $result);
|
|
|
|
$result=str_replace(">", ">", $result);
|
|
|
|
$result=str_replace("\"", """, $result);
|
|
|
|
$result=str_replace("Ä", "Ä", $result);
|
|
|
|
$result=str_replace("Ö", "Ö", $result);
|
|
|
|
$result=str_replace("Ü", "Ü", $result);
|
|
|
|
$result=str_replace("ä", "ä", $result);
|
|
|
|
$result=str_replace("ö", "ö", $result);
|
|
|
|
$result=str_replace("ü", "ü", $result);
|
|
|
|
$result=str_replace("ß", "ß", $result);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2011-07-22 08:30:52 +04:00
|
|
|
/**
|
|
|
|
* do the initial handshake
|
|
|
|
* @param array params
|
|
|
|
*/
|
|
|
|
public static function handshake($params){
|
|
|
|
$auth=(isset($params['auth']))?$params['auth']:false;
|
|
|
|
$user=(isset($params['user']))?$params['user']:false;
|
|
|
|
$time=(isset($params['timestamp']))?$params['timestamp']:false;
|
|
|
|
$now=time();
|
|
|
|
if($now-$time>(10*60)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>timestamp is more then 10 minutes old</error>
|
|
|
|
</root>");
|
|
|
|
}
|
|
|
|
if($auth and $user and $time){
|
2012-05-03 15:06:08 +04:00
|
|
|
$query=OCP\DB::prepare("SELECT user_id, user_password_sha256 from *PREFIX*media_users WHERE user_id=?");
|
2011-07-22 08:30:52 +04:00
|
|
|
$users=$query->execute(array($user))->fetchAll();
|
|
|
|
if(count($users)>0){
|
|
|
|
$pass=$users[0]['user_password_sha256'];
|
|
|
|
$key=hash('sha256',$time.$pass);
|
|
|
|
if($key==$auth){
|
|
|
|
$token=hash('sha256','oc_media_'.$key);
|
|
|
|
OC_MEDIA_COLLECTION::$uid=$users[0]['user_id'];
|
|
|
|
$date=date('c');//todo proper update/add/clean dates
|
|
|
|
$songs=OC_MEDIA_COLLECTION::getSongCount();
|
|
|
|
$artists=OC_MEDIA_COLLECTION::getArtistCount();
|
|
|
|
$albums=OC_MEDIA_COLLECTION::getAlbumCount();
|
2012-05-03 15:06:08 +04:00
|
|
|
$query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`session_id`, `token`, `user_id`, `start`) VALUES (NULL, ?, ?, now());");
|
2011-07-22 08:30:52 +04:00
|
|
|
$query->execute(array($token,$user));
|
|
|
|
$expire=date('c',time()+600);
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<auth>$token</auth>
|
|
|
|
<version>350001</version>
|
|
|
|
<update>$date</update>
|
|
|
|
<add>$date</add>
|
|
|
|
<clean>$date</clean>
|
|
|
|
<songs>$songs</songs>
|
|
|
|
<artists>$artists</artists>
|
|
|
|
<albums>$albums</albums>\
|
|
|
|
<session_length>600</session_length>
|
|
|
|
<session_expire>$expire</session_expire>
|
|
|
|
<tags>0</tags>
|
|
|
|
<videos>0</videos>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
}else{
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Missing arguments</error>
|
|
|
|
</root>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function ping($params){
|
|
|
|
if(isset($params['auth'])){
|
|
|
|
if(self::checkAuth($params['auth'])){
|
|
|
|
self::updateAuth($params['auth']);
|
|
|
|
}else{
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
echo('<version>350001</version>');
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function checkAuth($auth){
|
|
|
|
if(is_array($auth)){
|
|
|
|
if(isset($auth['auth'])){
|
|
|
|
$auth=$auth['auth'];
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//remove old sessions
|
2012-05-03 15:06:08 +04:00
|
|
|
$query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW()-600)");
|
2011-07-22 08:30:52 +04:00
|
|
|
$query->execute();
|
|
|
|
|
2012-05-03 15:06:08 +04:00
|
|
|
$query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?");
|
2011-07-22 08:30:52 +04:00
|
|
|
$users=$query->execute(array($auth))->fetchAll();
|
|
|
|
if(count($users)>0){
|
|
|
|
OC_MEDIA_COLLECTION::$uid=$users[0]['user_id'];
|
|
|
|
return $users[0]['user_id'];
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function updateAuth($auth){
|
2012-05-03 15:06:08 +04:00
|
|
|
$query=OCP\DB::prepare("UPDATE *PREFIX*media_sessions SET start=CURRENT_TIMESTAMP WHERE token=?");
|
2011-07-22 08:30:52 +04:00
|
|
|
$query->execute(array($auth));
|
|
|
|
}
|
|
|
|
|
|
|
|
private static function printArtist($artist){
|
|
|
|
$albums=count(OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']));
|
|
|
|
$songs=count(OC_MEDIA_COLLECTION::getSongs($artist['artist_id']));
|
|
|
|
$id=$artist['artist_id'];
|
2012-01-24 05:56:38 +04:00
|
|
|
$name=self::fixXmlString($artist['artist_name']);
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("\t<artist id='$id'>\n");
|
|
|
|
echo("\t\t<name>$name</name>\n");
|
|
|
|
echo("\t\t<albums>$albums</albums>\n");
|
|
|
|
echo("\t\t<songs>$songs</songs>\n");
|
|
|
|
echo("\t\t<rating>0</rating>\n");
|
|
|
|
echo("\t\t<preciserating>0</preciserating>\n");
|
|
|
|
echo("\t</artist>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
private static function printAlbum($album,$artistName=false){
|
|
|
|
if(!$artistName){
|
|
|
|
$artistName=OC_MEDIA_COLLECTION::getArtistName($album['album_artist']);
|
|
|
|
}
|
2012-01-24 05:56:38 +04:00
|
|
|
$artistName=self::fixXmlString($artistName);
|
2011-07-22 08:30:52 +04:00
|
|
|
$songs=count(OC_MEDIA_COLLECTION::getSongs($album['album_artist'],$album['album_id']));
|
|
|
|
$id=$album['album_id'];
|
2012-01-24 05:56:38 +04:00
|
|
|
$name=self::fixXmlString($album['album_name']);
|
2011-07-22 08:30:52 +04:00
|
|
|
$artist=$album['album_artist'];
|
|
|
|
echo("\t<album id='$id'>\n");
|
|
|
|
echo("\t\t<name>$name</name>\n");
|
|
|
|
echo("\t\t<artist id='$artist'>$artistName</artist>\n");
|
|
|
|
echo("\t\t<tracks>$songs</tracks>\n");
|
|
|
|
echo("\t\t<rating>0</rating>\n");
|
2012-01-24 05:56:38 +04:00
|
|
|
echo("\t\t<year>0</year>\n"); /* make Viridian happy */
|
|
|
|
echo("\t\t<disk>1</disk>\n"); /* make Viridian happy */
|
|
|
|
echo("\t\t<art> </art>\n"); /* single space to make quickplay happy enough */
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("\t\t<preciserating>0</preciserating>\n");
|
|
|
|
echo("\t</album>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
private static function printSong($song,$artistName=false,$albumName=false){
|
|
|
|
if(!$artistName){
|
|
|
|
$artistName=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
|
|
|
|
}
|
|
|
|
if(!$albumName){
|
|
|
|
$albumName=OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
|
|
|
|
}
|
2012-01-24 05:56:38 +04:00
|
|
|
$artistName=self::fixXmlString($artistName);
|
|
|
|
$albumName=self::fixXmlString($albumName);
|
2011-07-22 08:30:52 +04:00
|
|
|
$id=$song['song_id'];
|
2012-01-24 05:56:38 +04:00
|
|
|
$name=self::fixXmlString($song['song_name']);
|
2011-07-22 08:30:52 +04:00
|
|
|
$artist=$song['song_artist'];
|
|
|
|
$album=$song['song_album'];
|
|
|
|
echo("\t<song id='$id'>\n");
|
|
|
|
echo("\t\t<title>$name</title>\n");
|
|
|
|
echo("\t\t<artist id='$artist'>$artistName</artist>\n");
|
|
|
|
echo("\t\t<album id='$album'>$albumName</album>\n");
|
2012-05-07 22:22:55 +04:00
|
|
|
$url=OCP\Util::linkToRemote('ampache')."server/xml.server.php/?action=play&song=$id&auth={$_GET['auth']}";
|
2012-01-24 05:56:38 +04:00
|
|
|
$url=self::fixXmlString($url);
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("\t\t<url>$url</url>\n");
|
|
|
|
echo("\t\t<time>{$song['song_length']}</time>\n");
|
|
|
|
echo("\t\t<track>{$song['song_track']}</track>\n");
|
|
|
|
echo("\t\t<size>{$song['song_size']}</size>\n");
|
2012-01-24 05:56:38 +04:00
|
|
|
echo("\t\t<art> </art>\n"); /* single space to make Viridian happy enough */
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("\t\t<rating>0</rating>\n");
|
|
|
|
echo("\t\t<preciserating>0</preciserating>\n");
|
|
|
|
echo("\t</song>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function artists($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$filter=isset($params['filter'])?$params['filter']:'';
|
|
|
|
$exact=isset($params['exact'])?($params['exact']=='true'):false;
|
|
|
|
$artists=OC_MEDIA_COLLECTION::getArtists($filter,$exact);
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
foreach($artists as $artist){
|
|
|
|
self::printArtist($artist);
|
|
|
|
}
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function artist_songs($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
2011-08-17 02:07:08 +04:00
|
|
|
$filter=isset($params['filter'])?$params['filter']:'';
|
2011-07-22 08:30:52 +04:00
|
|
|
$songs=OC_MEDIA_COLLECTION::getSongs($filter);
|
|
|
|
$artist=OC_MEDIA_COLLECTION::getArtistName($filter);
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
foreach($songs as $song){
|
|
|
|
self::printSong($song,$artist);
|
|
|
|
}
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function artist_albums($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
global $SITEROOT;
|
|
|
|
$filter=$params['filter'];
|
|
|
|
$albums=OC_MEDIA_COLLECTION::getAlbums($filter);
|
|
|
|
$artist=OC_MEDIA_COLLECTION::getArtistName($filter);
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
foreach($albums as $album){
|
|
|
|
self::printAlbum($album,$artist);
|
|
|
|
}
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function albums($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$filter=isset($params['filter'])?$params['filter']:'';
|
|
|
|
$exact=isset($params['exact'])?($params['exact']=='true'):false;
|
|
|
|
$albums=OC_MEDIA_COLLECTION::getAlbums(0,$filter,$exact);
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
foreach($albums as $album){
|
2012-01-24 05:56:38 +04:00
|
|
|
self::printAlbum($album,false);
|
2011-07-22 08:30:52 +04:00
|
|
|
}
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function album_songs($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$songs=OC_MEDIA_COLLECTION::getSongs(0,$params['filter']);
|
|
|
|
if(count($songs)>0){
|
|
|
|
$artist=OC_MEDIA_COLLECTION::getArtistName($songs[0]['song_artist']);
|
|
|
|
}
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
foreach($songs as $song){
|
|
|
|
self::printSong($song,$artist);
|
|
|
|
}
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function songs($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$filter=isset($params['filter'])?$params['filter']:'';
|
|
|
|
$exact=isset($params['exact'])?($params['exact']=='true'):false;
|
|
|
|
$songs=OC_MEDIA_COLLECTION::getSongs(0,0,$filter,$exact);
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
foreach($songs as $song){
|
|
|
|
self::printSong($song);
|
|
|
|
}
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function song($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if($song=OC_MEDIA_COLLECTION::getSong($params['filter'])){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
self::printSong($song);
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function play($params){
|
|
|
|
$username=!self::checkAuth($params);
|
|
|
|
if($username){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if($song=OC_MEDIA_COLLECTION::getSong($params['song'])){
|
2011-07-29 23:36:03 +04:00
|
|
|
OC_Util::setupFS($song["song_user"]);
|
2011-07-22 08:30:52 +04:00
|
|
|
|
2011-07-29 23:36:03 +04:00
|
|
|
header('Content-type: '.OC_Filesystem::getMimeType($song['song_path']));
|
2011-07-22 08:30:52 +04:00
|
|
|
header('Content-Length: '.$song['song_size']);
|
2011-07-29 23:36:03 +04:00
|
|
|
OC_Filesystem::readfile($song['song_path']);
|
2011-07-22 08:30:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function url_to_song($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$url=$params['url'];
|
|
|
|
$songId=substr($url,strrpos($url,'song=')+5);
|
|
|
|
if($song=OC_MEDIA_COLLECTION::getSong($songId)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
self::printSong($song);
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function search_songs($params){
|
|
|
|
if(!self::checkAuth($params)){
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo("<root>
|
|
|
|
<error code='400'>Invalid login</error>
|
|
|
|
</root>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$filter=$params['filter'];
|
|
|
|
$artists=OC_MEDIA_COLLECTION::getArtists($filter);
|
|
|
|
$albums=OC_MEDIA_COLLECTION::getAlbums(0,$filter);
|
|
|
|
$songs=OC_MEDIA_COLLECTION::getSongs(0,0,$filter);
|
|
|
|
foreach($artists as $artist){
|
|
|
|
$songs=array_merge($songs,OC_MEDIA_COLLECTION::getSongs($artist['artist_id']));
|
|
|
|
}
|
|
|
|
foreach($albums as $album){
|
|
|
|
$songs=array_merge($songs,OC_MEDIA_COLLECTION::getSongs($album['album_artist'],$album['album_id']));
|
|
|
|
}
|
2012-01-24 05:56:38 +04:00
|
|
|
echo('<?xml version="1.0" encoding="UTF-8"?>');
|
2011-07-22 08:30:52 +04:00
|
|
|
echo('<root>');
|
|
|
|
foreach($songs as $song){
|
|
|
|
self::printSong($song);
|
|
|
|
}
|
|
|
|
echo('</root>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-18 21:37:54 +04:00
|
|
|
?>
|