diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-07-22 06:30:52 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-07-22 06:30:52 +0200 |
commit | 38f1cffab39ae763f3929bcc37e6f8746f582083 (patch) | |
tree | a833cacb98acc372f40dda0c757904b4cba9c331 /apps/media/tomahawk.php | |
parent | f441059b015b01af1fcafcdeeef8727f19d0d2d5 (diff) | |
download | nextcloud-server-38f1cffab39ae763f3929bcc37e6f8746f582083.tar.gz nextcloud-server-38f1cffab39ae763f3929bcc37e6f8746f582083.zip |
import media app
Diffstat (limited to 'apps/media/tomahawk.php')
-rw-r--r-- | apps/media/tomahawk.php | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php new file mode 100644 index 00000000000..873a4e2092c --- /dev/null +++ b/apps/media/tomahawk.php @@ -0,0 +1,81 @@ +<?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/>. +* +*/ + +$_POST=$_GET; //debug + +require_once('../../lib/base.php'); +require_once('lib_collection.php'); + +$user=isset($_POST['user'])?$_POST['user']:''; +$pass=isset($_POST['pass'])?$_POST['pass']:''; +if(OC_USER::checkPassword($user,$pass)){ + OC_UTIL::setupFS($user); + OC_MEDIA_COLLECTION::$uid=$user; +}else{ + exit; +} + +if(isset($_POST['play']) and $_POST['play']=='true'){ + if(!isset($_POST['song'])){ + exit; + } + $song=OC_MEDIA_COLLECTION::getSong($_POST['song']); + $ftype=OC_FILESYSTEM::getMimeType( $song['song_path'] ); + header('Content-Type:'.$ftype); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Length: '.OC_FILESYSTEM::filesize($song['song_path'])); + + OC_FILESYSTEM::readfile($song['song_path']); +} + +$artist=isset($_POST['artist'])?'%'.$_POST['artist'].'%':''; +$album=isset($_POST['album'])?'%'.$_POST['album'].'%':''; +$song=isset($_POST['song'])?$_POST['song']:''; + +$artist=OC_MEDIA_COLLECTION::getArtistId($artist); +$album=OC_MEDIA_COLLECTION::getAlbumId($album,$artist); + +$songs=OC_MEDIA_COLLECTION::getSongs($artist,$album,$song); + +$baseUrl=OC_UTIL::getServerURL().OC_HELPER::linkTo('media','tomahawk.php'); + +$results=array(); +foreach($songs as $song) { + $results[] = (Object) array( + 'artist' => OC_MEDIA_COLLECTION::getArtistName($song['song_artist']), + 'album' => OC_MEDIA_COLLECTION::getAlbumName($song['song_album']), + 'track' => $song['song_name'], + 'source' => 'ownCloud', + 'mimetype' => OC_FILESYSTEM::getMimeType($song['song_path']), + 'extension' => substr($song['song_path'],strrpos($song['song_path'],'.')), + 'url' => $baseUrl.'?play=true&song='.$song['song_id'], + 'bitrate' => round($song['song_id']/$song['song_length'],0), + 'duration' => round($song['song_length'],0), + 'size' => $song['song_size'], + 'score' => (float)1.0 + ); +} +echo json_encode($results); +?>
\ No newline at end of file |