Exemple #1
0
 /**
  * Calls the cleanup method of the scanner
  */
 public static function run()
 {
     $app = new Music();
     $container = $app->getContainer();
     // remove orphaned entities
     $container->query('Helper')->cleanUp();
     // find covers - TODO performance stuff - maybe just call this once in an hour
     $container->query('AlbumBusinessLayer')->findCovers();
     // remove expired sessions
     $container->query('AmpacheSessionMapper')->cleanUp();
 }
Exemple #2
0
 /**
  * Invoke auto update of music database after item gets shared
  * @param array $params contains the params of the added share
  */
 public static function itemShared($params)
 {
     $app = new Music();
     $container = $app->getContainer();
     if ($params['itemType'] === 'folder') {
         $backend = new \OC_Share_Backend_Folder();
         foreach ($backend->getChildren($params['itemSource']) as $child) {
             $container->query('Scanner')->updateById((int) $child['source'], $params['shareWith']);
         }
     } else {
         if ($params['itemType'] === 'file') {
             $container->query('Scanner')->updateById((int) $params['itemSource'], $params['shareWith']);
         }
     }
 }
Exemple #3
0
 public function search($query)
 {
     $app = new Music();
     $c = $app->getContainer();
     $artistMapper = $c->query('ArtistMapper');
     $albumMapper = $c->query('AlbumMapper');
     $trackMapper = $c->query('TrackMapper');
     $urlGenerator = $c->getServer()->getURLGenerator();
     $userId = $c->query('UserId');
     $l10n = $c->query('L10N');
     $pattern = $query;
     $results = array();
     $artists = $artistMapper->findAllByName($pattern, $userId, true);
     $container = '';
     $text = '';
     foreach ($artists as $artist) {
         $name = $artist->name;
         $link = $urlGenerator->linkToRoute('music.page.index') . '#/artist/' . $artist->id;
         $type = (string) $l10n->t('Artists');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     $albums = $albumMapper->findAllByName($pattern, $userId, true);
     foreach ($albums as $album) {
         $name = $album->name;
         $link = $urlGenerator->linkToRoute('music.page.index') . '#/album/' . $album->id;
         $type = (string) $l10n->t('Albums');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     $tracks = $trackMapper->findAllByName($pattern, $userId, true);
     foreach ($tracks as $track) {
         $name = $track->title;
         $link = $urlGenerator->linkToRoute('music.page.index') . '#/track/' . $track->id;
         $type = (string) $l10n->t('Tracks');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     return $results;
 }
Exemple #4
0
 /**
  * Invoke auto update of music database after file update or file creation
  * @param array $params contains a key value pair for the path of the file/dir
  */
 public static function updated($params)
 {
     $app = new Music();
     $container = $app->getContainer();
     $container->query('Scanner')->updateByPath($params['path']);
 }
Exemple #5
0
<?php

/**
 * ownCloud - Music app
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Morris Jobke <*****@*****.**>
 * @copyright Morris Jobke 2013, 2014
 */
namespace OCA\Music;

use OCA\Music\App\Music;
$app = new Music();
$c = $app->getContainer();
$c->query('API')->addScript('public/settings-user');
$c->query('API')->addStyle('settings-user');
$tmpl = new \OCP\Template($c->query('AppName'), 'settings-user');
$tmpl->assign('path', $c->query('Config')->getUserValue($c->query('UserId'), $c->query('AppName'), 'path'));
$tmpl->assign('ampacheKeys', $c->query('AmpacheUserMapper')->getAll($c->query('UserId')));
$tmpl->assign('URLGenerator', $c->query('URLGenerator'));
return $tmpl->fetchPage();
Exemple #6
0
<?php

/**
 * ownCloud - Music app
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Morris Jobke <*****@*****.**>
 * @copyright Morris Jobke 2014
 */
namespace OCA\Music;

use OCA\Music\App\Music;
$app = new Music();
$app->registerRoutes($this, array('routes' => array(array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'), array('name' => 'log#log', 'url' => '/api/log', 'verb' => 'POST'), array('name' => 'api#collection', 'url' => '/api/collection', 'verb' => 'GET'), array('name' => 'api#artists', 'url' => '/api/artists', 'verb' => 'GET'), array('name' => 'api#artist', 'url' => '/api/artist/{artistIdOrSlug}', 'verb' => 'GET'), array('name' => 'api#albums', 'url' => '/api/albums', 'verb' => 'GET'), array('name' => 'api#album', 'url' => '/api/album/{albumIdOrSlug', 'verb' => 'GET'), array('name' => 'api#cover', 'url' => '/api/album/{albumIdOrSlug}/cover', 'verb' => 'GET'), array('name' => 'api#tracks', 'url' => '/api/tracks', 'verb' => 'GET'), array('name' => 'api#track', 'url' => '/api/track/{trackIdOrSlug}', 'verb' => 'GET'), array('name' => 'api#trackByFileId', 'url' => '/api/file/{fileId}', 'verb' => 'GET'), array('name' => 'api#download', 'url' => '/api/file/{fileId}/download', 'verb' => 'GET'), array('name' => 'api#scan', 'url' => '/api/scan', 'verb' => 'GET'), array('name' => 'playlistApi#getAll', 'url' => '/api/playlists', 'verb' => 'GET'), array('name' => 'playlistApi#create', 'url' => '/api/playlists', 'verb' => 'POST'), array('name' => 'playlistApi#get', 'url' => '/api/playlists/{id}', 'verb' => 'GET'), array('name' => 'playlistApi#delete', 'url' => '/api/playlists/{id}', 'verb' => 'DELETE'), array('name' => 'playlistApi#update', 'url' => '/api/playlists/{id}', 'verb' => 'PUT'), array('name' => 'playlistApi#addTracks', 'url' => '/api/playlists/{id}/add', 'verb' => 'POST'), array('name' => 'playlistApi#removeTracks', 'url' => '/api/playlists/{id}/remove', 'verb' => 'POST'), array('name' => 'setting#userPath', 'url' => '/settings/user/path', 'verb' => 'POST'), array('name' => 'setting#addUserKey', 'url' => '/settings/userkey/add', 'verb' => 'POST'), array('name' => 'setting#removeUserKey', 'url' => '/settings/userkey/remove', 'verb' => 'POST'), array('name' => 'ampache#ampache', 'url' => '/ampache/server/xml.server.php', 'verb' => 'GET'), array('name' => 'ampache#ampache2', 'url' => '/ampache/server/xml.server.php', 'verb' => 'POST'))));