break;
 case 'get_albums':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'], $arguments['search']));
     break;
 case 'get_songs':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'], $arguments['album'], $arguments['search']));
     break;
 case 'get_path_info':
     if (OC_Filesystem::file_exists($arguments['path'])) {
         $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
         if ($songId == 0) {
             unset($_SESSION['collection']);
             $songId = OC_MEDIA_SCANNER::scanFile($arguments['path']);
         }
         if ($songId > 0) {
             $song = OC_MEDIA_COLLECTION::getSong($songId);
             $song['artist'] = OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
             $song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
             OC_JSON::encodedPrint($song);
         }
     }
     break;
 case 'play':
     ob_end_clean();
     $ftype = OC_Filesystem::getMimeType($arguments['path']);
     $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
     OC_MEDIA_COLLECTION::registerPlay($songId);
     header('Content-Type:' . $ftype);
     // calc an offset of 24 hours
     $offset = 3600 * 24;
     // calc the string in GMT not localtime and add the offset
 public static function url_to_song($params)
 {
     if (!self::checkAuth($params)) {
         echo "<root>\n\t<error code='400'>Invalid login</error>\n</root>";
         return;
     }
     $url = $params['url'];
     $songId = substr($url, strrpos($url, 'song=') + 5);
     if ($song = OC_MEDIA_COLLECTION::getSong($songId)) {
         echo '<root>';
         self::printSong($song);
         echo '</root>';
     }
 }
require_once '../../lib/base.php';
OC_JSON::checkAppEnabled('media');
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');