public function processMusic() { if ($this->site->lookupmusic == 1) { $music = new Music($this->echooutput); $music->processMusicReleases(); } }
/** * Get all the songs for an artist * * @param string $artist * * @return array */ public static function getSongs($artist) { // query the MPD database $result = Music::send('search', 'artist', $artist); // get the list of songs return Music::buildSongList($result['values']); }
public static function getList() { // get the list $result = Music::send('listallinfo'); // return the values return Music::buildSongList($result['values']); }
public static function replacePlaylist($args, $shuffle = false) { // connect to MPD static::connect(); // get the songs as defined by the arguments $songs = Music::getSongList($args); // get the ID of the song to play $song_id = array_pop($args); // clear the current playlist MPD::clear(); // a variable to save the ID of the song to play $mpd_id = null; // step through the songs foreach ($songs as $s) { // add each song to the playlist $values = MPD::send('addid', 'file://' . $s->filenamepath); // does this song correspond to the the song to play? if ($values['status'] == 'OK' && $s->id == $song_id) { $mpd_id = trim(substr($values['values'][0], 3)); } } // start playing the selected song if (!$shuffle && $mpd_id) { // turn off random play MPD::send('random', 0); // play the requested song MPD::send('playid', $mpd_id); } else { // turn on random play MPD::send('random', 1); // start playing MPD::send('play'); } }
public static function getSongs($playlist) { // send the command to MPD $results = Music::send('listplaylistinfo', $playlist); // return the list of songs return Music::buildSongList($results['values']); }
/** * Render a list page * * @param string $page_title * The page title (displayed in the top bar) * * @param array|null $album_stats * The album stats, if this is a list of songs from an album * * @param array $list_items * The list of items to display * * @return string * The HTML of the rendered page */ public static function render($page_title, $previous, $shuffle, $allsongs, $list) { // instantiate the template engine $parser = new Rain\Tpl(); // assign the values to the template parser $parser->assign(array('page_title' => $page_title, 'list' => $list, 'previous' => $previous, 'shuffle' => $shuffle, 'all_songs' => $allsongs, 'now_playing' => Music::isPlayingOrPaused(), 'album_stats' => $album_stats, 'include_all_songs' => $include_all_songs, 'base_uri' => static::$base_uri, 'object_type' => $type)); // return the HTML return $parser->draw("list-page", true); }
public function actionDel($mid, $song) { $musicModel = Music::model(); if ($musicModel->deleteByPk($mid)) { if (unlink('uploads/' . $song)) { $this->redirect(array('index')); } } }
protected function postFilter() { parent::postFilter(); if ($this->play !== null) { $this->xml->setAttribute('play', $this->play); } if ($this->looping !== null) { $this->xml->setAttribute('looping', $this->looping); } }
/** * Render a list page * * @param Song $song * The song that is currently playing * * @return string * The HTML of the rendered page */ public static function render($song, $previous) { // instantiate the template engine $parser = new Rain\Tpl(); // get the image data for the song $image_data = Song::getImageData($song['Artist'], $song['Album'], 320); // assign the values to the template parser $parser->assign(array('image' => $image_data, 'song' => $song, 'volume' => Music::getVolume(), 'previous' => $previous)); // return the HTML return $parser->draw("now-playing-page", true); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Music::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, '您请求的页面不存在。'); } } return $this->_model; }
public function run() { #if($this->_model===null) if ($this->getController()->_model === null) { if (isset($_GET['id'])) { $this->getController()->_model = Music::model()->findbyPk($_GET['id']); } if ($this->getController()->_model == null) { throw new CHttpException(404, '您请求的页面不存在。'); } } echo chr(239) . chr(187) . chr(191) . $this->getController()->_model->lyric; }
public function common() { $common = array(); //选择音乐 $sql = "SELECT song,singer,special FROM {{music}} WHERE sel=1"; $common['music'] = Music::model()->findAllBySql($sql); //音乐学则结束 $sql = "SELECT cname,cid FROM {{category}} LIMIT 10"; $common['nav'] = Category::model()->findAllBySql($sql); $sql = "SELECT title,aid FROM {{article}} WHERE type=1 ORDER BY time DESC LIMIT 7 "; $common['hot'] = $this->findAllBySql($sql); $sql = "SELECT title,aid FROM {{article}} ORDER BY time DESC LIMIT 7 "; $common['new'] = $this->findAllBySql($sql); return $common; }
/** * 音乐页面 * * @param int $id * @return Response */ public function titlePage($id) { // fetch music $music = Music::find($id); // collect the total counts $total = []; foreach ($music->programs as $pm) { empty($total[$pm->dates->year]) and $total[$pm->dates->year] = 0; $total[$pm->dates->year]++; } $total = self::fillChartData($total); // TDK $title = implode(' - ', [$music->title, $music->artists->pluck('name')->implode(', ')]); $description = '飞鱼秀歌单, 飞鱼秀音乐列表'; // render return View::make('music.song')->with('music', $music)->with('total', $total)->with('title', $title)->with('description', $description); }
/** * Process file import data into application data * * @return void */ private function processFileImport() { // Disable query log to conserve on memory DB::connection()->disableQueryLog(); // Find first pending file import and eager load the csvRows $this->csv_import = CsvImport::where('status', 'pending')->with('csvRows')->first(); if (!$this->csv_import) { printf("%s \n", "Nothing to process."); exit; } // Change the status of the import to avoid it being processed again. $this->csv_import->status = 'processing'; $this->csv_import->save(); if (count($this->csv_import->fileImportContent)) { // Get the header from the import $header = $this->csv_import->fileImportContent->first()->header; // Flip the values to keys and explode into array $header = array_flip(explode(',', $header)); foreach ($this->csv_import->fileImportContent as $row) { // Convert the raw row data into array $row_array = explode(',', $row->content); // Build array of import properties $import_array = $header; // Match data array to the header array foreach ($import_array as $index => $key) { $import_array[$index] = $row_array[$key]; } /** * Here we can perform additional validation * for each data field and save it to the database */ // Build array of parameters for our user import $user = User::firstOrCreate(['first_name' => $import_array['first_name'], 'last_name' => $import_array['last_name'], 'email' => $import_array['email']]); $movies = Movies::firstOrCreate(['user_id' => $user->id, 'movie_list' => $import_array['movies']]); $music = Music::firstOrCreate(['user_id' => $user->id, 'music_list' => $import_array['music']]); } $this->csv_import->status = 'processed'; $this->csv_import->save(); } else { $this->csv_import->status = 'error'; $this->csv_import->save(); //Log error exit; } }
/** * Execute the console command. * * @return mixed */ public function handle() { $list = []; $n = 0; DB::table('tmp_musics')->chunk(10000, function ($data) use(&$list, &$n) { foreach ($data as $record) { ++$n; // 合并整段记录 $key = implode('_', [$record->audio_part, $record->acrid]); if (empty($list) or isset($list[$key])) { $list[$key][] = $record; if (!empty($record->acrid)) { continue; } // 插入数据 } else { // 插入歌手记录 $list = current($list); $first = current($list); $end = end($list); $artistIds = []; foreach (explode('|', $first->artists) as $name) { $artist = Artist::firstOrCreate(['name' => $name]); $artist->increment('counts', 1); $artistIds[] = $artist->id; } // 插入音乐记录 $music = Music::firstOrCreate(['title' => $first->title, 'album' => $first->album, 'genres' => $first->genres, 'label' => $first->label, 'release_date' => $first->release_date, 'acrid' => $first->acrid, 'isrc' => $first->isrc, 'upc' => $first->upc, 'external_metadata' => $first->external_metadata]); // 插入音乐歌手记录 $music->artists()->sync($artistIds); // 插入节目音乐记录 Program::where('date', $first->program_date)->first()->musics()->attach($music->id, ['program_part' => $first->audio_part, 'start_sec' => $first->audio_start_sec, 'end_sec' => $end->audio_start_sec, 'url' => self::getQiniuUrl($first->program_date, $first->audio_start_sec, $end->audio_start_sec)]); // 插入节目歌手记录 foreach ($music->artists as $artist) { Program::where('date', $first->program_date)->first()->artists()->attach($artist->id); } // 输出日志 $this->info(implode("\t", [$n, $music->id, $first->artists, $first->title])); } // 清空列表 $list = []; } }); }
public function run() { header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); if (isset($_GET['id'])) { $code = chr(239) . chr(187) . chr(191) . "<list>\n"; $code .= "<m opened=\"1\" label=\"播放列表\">\n"; $ids = explode("_", trim($_GET['id'])); foreach ($ids as $id) { $this->getController()->_model = Music::model()->findbyPk($id); $url = rawurlencode($this->getController()->_model->url); $url = preg_replace(array('/%3A/i', '/%2F/i', '/%3D/i', '/%27/i', '/%22/i', '/%2A/i'), array(':', '/', '=', '\'', '+'), $url); $siteUrl = 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->urlManager->baseUrl; $code .= "\t<m type=\"\" src=\"{$url}\" lrc=\"{$siteUrl}?r=music/lrc&id={$this->getController()->_model->id}\" label=\"{$this->getController()->_model->name}-{$this->getController()->_model->artist->name}\" />\n"; } $code .= "</m>\n"; $code .= "</list>"; echo $code; } if ($this->getController()->_model == null) { throw new CHttpException(404, '您请求的页面不存在。'); } }
protected function afterFind() { parent::afterFind(); $this->_tags = $this->_oldTags = ItemsTags::returnTagsString(ItemsTags::MUSIC_TYPE, $this->id); Music::model()->updateCounters(array('click' => 1), 'id=:id', array(':id' => $this->id)); }
$song = $song == 'shuffle' ? 'shuffle' : Music::decode($song); // clear the playlist Music::send('clear'); // get the list of songs $songs = Album::getSongs($artist, $album); // load the playlist with the requested songs (and figure out the current // song position) $pos = 0; for ($i = 0; $i < count($songs); $i++) { // add the current song to the current playlist Music::send('add', $songs[$i]['file']); // see if the current song is the one the user selected if ($songs[$i]['file'] == $song) { $pos = $i; } } // turn off "shuffle" Music::shuffle(false); // is the current song "shuffle" if ($song == 'shuffle') { // choose a random song $pos = rand(0, count($songs) - 1); // turn on shuffle Music::shuffle(true); } // start playing the selected song Music::send('play', $pos); // redirect to "now playing" header('Location: /'); die; });
function updateMusicInfo($artist, $album, $year) { $db = new DB(); $gen = new Genres(); $music = new Music(); $mus = array(); $amaz = $music->fetchAmazonProperties($artist . " - " . $album); if (!$amaz) { return false; } //load genres $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE); $genreassoc = array(); foreach ($defaultGenres as $dg) { $genreassoc[$dg['ID']] = strtolower($dg['title']); } // // get album properties // $mus['coverurl'] = (string) $amaz->Items->Item->MediumImage->URL; if ($mus['coverurl'] != "") { $mus['cover'] = 1; } else { $mus['cover'] = 0; } $mus['title'] = (string) $amaz->Items->Item->ItemAttributes->Title; if (empty($mus['title'])) { $mus['title'] = $album; } $mus['asin'] = (string) $amaz->Items->Item->ASIN; $mus['url'] = (string) $amaz->Items->Item->DetailPageURL; $mus['url'] = str_replace("%26tag%3Dws", "%26tag%3Dopensourceins%2D21", $mus['url']); $mus['salesrank'] = (string) $amaz->Items->Item->SalesRank; if ($mus['salesrank'] == "") { $mus['salesrank'] = 'null'; } $mus['artist'] = (string) $amaz->Items->Item->ItemAttributes->Artist; if (empty($mus['artist'])) { $mus['artist'] = $artist; } $mus['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher; $mus['releasedate'] = $db->escapeString((string) $amaz->Items->Item->ItemAttributes->ReleaseDate); if ($mus['releasedate'] == "''") { $mus['releasedate'] = 'null'; } $mus['review'] = ""; if (isset($amaz->Items->Item->EditorialReviews)) { $mus['review'] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content)); } $mus['year'] = $year; if ($mus['year'] == "" && $mus['releasedate'] != 'null') { $mus['year'] = substr($mus['releasedate'], 1, 4); } $mus['tracks'] = ""; if (isset($amaz->Items->Item->Tracks)) { $tmpTracks = (array) $amaz->Items->Item->Tracks->Disc; $tracks = $tmpTracks['Track']; $mus['tracks'] = is_array($tracks) && !empty($tracks) ? implode('|', $tracks) : ''; } $genreKey = -1; $genreName = ''; $amazGenres = (array) $amaz->Items->Item->BrowseNodes; foreach ($amazGenres as $amazGenre) { foreach ($amazGenre as $ag) { $tmpGenre = strtolower((string) $ag->Name); if (!empty($tmpGenre)) { if (in_array($tmpGenre, $genreassoc)) { $genreKey = array_search($tmpGenre, $genreassoc); $genreName = $tmpGenre; break; } else { //we got a genre but its not stored in our genre table $genreName = (string) $ag->Name; $genreKey = 'new genre to be added'; //$genreKey = $db->queryInsert(sprintf("INSERT INTO genres (`title`, `type`) VALUES (%s, %d)", $db->escapeString($genreName), Genres::MUSIC_TYPE)); break; } } } } $mus['musicgenre'] = $genreName; $mus['musicgenreID'] = $genreKey; $mus['amaz'] = $amaz->Items->Item; return $mus; }
<?php require_once "config.php"; require_once WWW_DIR . "/lib/adminpage.php"; require_once WWW_DIR . "/lib/music.php"; require_once WWW_DIR . "/lib/genres.php"; $page = new AdminPage(); $music = new Music(); $gen = new Genres(); $id = 0; // set the current action $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; if (isset($_REQUEST["id"])) { $id = $_REQUEST["id"]; $mus = $music->getMusicInfo($id); if (!$mus) { $page->show404(); } switch ($action) { case 'submit': $coverLoc = WWW_DIR . "covers/music/" . $id . '.jpg'; if ($_FILES['cover']['size'] > 0) { $tmpName = $_FILES['cover']['tmp_name']; $file_info = getimagesize($tmpName); if (!empty($file_info)) { move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc); } } $_POST['cover'] = file_exists($coverLoc) ? 1 : 0; $_POST['salesrank'] = empty($_POST['salesrank']) || !ctype_digit($_POST['salesrank']) ? "null" : $_POST['salesrank']; $_POST['releasedate'] = empty($_POST['releasedate']) || !strtotime($_POST['releasedate']) ? $mus['releasedate'] : date("Y-m-d H:i:s", strtotime($_POST['releasedate']));
<?php require_once WWW_DIR . "/lib/music.php"; require_once WWW_DIR . "/lib/category.php"; require_once WWW_DIR . "/lib/genres.php"; $music = new Music(); $cat = new Category(); $gen = new Genres(); if (!$users->isLoggedIn()) { $page->show403(); } $musiccats = $cat->getChildren(Category::CAT_PARENT_MUSIC); $mtmp = array(); foreach ($musiccats as $mcat) { $mtmp[$mcat['ID']] = $mcat; } $category = Category::CAT_PARENT_MUSIC; if (isset($_REQUEST["t"]) && array_key_exists($_REQUEST['t'], $mtmp)) { $category = $_REQUEST["t"] + 0; } $catarray = array(); $catarray[] = $category; $page->smarty->assign('catlist', $mtmp); $page->smarty->assign('category', $category); $browsecount = $music->getMusicCount($catarray, -1, $page->userdata["categoryexclusions"]); $offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0; $ordering = $music->getMusicOrdering(); $orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : ''; $results = $musics = array(); $results = $music->getMusicRange($catarray, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"]); foreach ($results as $result) {
} else { echo 'You have too many top friends. Please remove one.'; } ?> </tr> </table> </div> <div class="green_content_bottom"> </div> </div> <?php } ?> <?php $music = new Music($profile->username); if ($music->hasMusic) { ?> <div class="green_contentbox"> <div class="green_content_top"> <h3 class="content_box_header">Music Space</h3> </div> <div class="green_content"> <?php $music->displayMusicPlayer(); ?> <span>music player courtesy of <a href="http://www.playlist.com/">Project Playlist</a></span> </div> <div class="green_content_bottom"> </div>
function doUpdateMusicSettings() { global $user, $form, $permission; $music = new Music($user->username); $result = $music->updateMusicSettings($user->username, $_POST['pp_id'], $_POST['shuffle'], $_POST['autostart'], $_POST['color']); if ($result) { $_SESSION['success'] = true; $_SESSION['event'] = $result; header("Location: " . $_SERVER['HTTP_REFERER'] . ""); } else { $_SESSION['event'] = "Error Uploading File"; $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: " . $_SERVER['HTTP_REFERER'] . ""); } }
/** * Process untagged music releases using information from mediainfo if config permits. */ public function processMusicFromMediaInfo() { $processMediainfo = $this->pdo->getSetting('mediainfopath') != '' ? true : false; $processAudioSample = $this->pdo->getSetting('saveaudiopreview') == 1 ? true : false; $processMusic = $this->pdo->getSetting('lookupmusic') == 1 ? true : false; if ($processMusic && $processMediainfo && $processAudioSample) { $music = new Music($this->echooutput); $ret = $music->processMusicReleaseFromMediaInfo(); return $ret; } return false; }
<?php $music = new Music(); if (!$page->users->isLoggedIn()) { $page->show403(); } if (isset($_GET["id"]) && ctype_digit($_GET["id"])) { $mus = $music->getMusicInfo($_GET['id']); if (!$mus) { $page->show404(); } $page->smarty->assign('music', $mus); $page->title = "Info for " . $mus['title']; $page->meta_title = ""; $page->meta_keywords = ""; $page->meta_description = ""; $page->smarty->registerPlugin('modifier', 'ss', 'stripslashes'); $modal = false; if (isset($_GET['modal'])) { $modal = true; $page->smarty->assign('modal', true); } $page->content = $page->smarty->fetch('viewmusic.tpl'); if ($modal) { echo $page->content; } else { $page->render(); } }
<?php require_once "config.php"; require_once WWW_DIR . "/lib/adminpage.php"; require_once WWW_DIR . "/lib/music.php"; $page = new AdminPage(); $m = new Music(); $page->title = "Music List"; $mcount = $m->getCount(); $offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; $page->smarty->assign('pagertotalitems', $mcount); $page->smarty->assign('pageroffset', $offset); $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE); $page->smarty->assign('pagerquerybase', WWW_TOP . "/music-list.php?offset="); $pager = $page->smarty->fetch($page->getCommonTemplate("pager.tpl")); $page->smarty->assign('pager', $pager); $musiclist = $m->getRange($offset, ITEMS_PER_PAGE); $page->smarty->assign('musiclist', $musiclist); $page->content = $page->smarty->fetch('music-list.tpl'); $page->render();
include 'database_connection.php'; include 'classes/MediaItem.php'; include 'classes/Game.php'; include 'classes/Book.php'; include 'classes/Music.php'; include 'classes/Movie.php'; $game = new Game(); $game->setTitle('Watch Dogs'); $game->setDesc('Crappy shit wannabe hacker game'); $game->setRating(1); $game->setTags(['dnt']); print '<p>' . ($game->save() ? "Saving successful" : "Saving unsuccessful") . '</p>'; $book = new Book(); $book->setTitle('Momo'); $book->setDesc('Dreamy and so on'); $book->setRating(4); $book->setTags(['tc']); print '<p>' . ($book->save() ? "Saving successful" : "Saving unsuccessful") . '</p>'; $movie = new Movie(); $movie->setTitle('The big short'); $movie->setDesc('Capitalism'); $movie->setRating(3); $movie->setTags(['tc', 'wtf']); print '<p>' . ($movie->save() ? "Saving successful" : "Saving unsuccessful") . '</p>'; $music = new Music(); $music->setTitle('Bravo Hits 666'); $music->setDesc('Diabolic Bullshit'); $music->setRating(1); $music->setTags(['dnt']); print '<p>' . ($music->save() ? "Saving successful" : "Saving unsuccessful") . '</p>';
<?php require_once '../classes/Music.class.php'; require_once '../settings.php'; global $MUSIC; $MUSIC = new Music(); $stats = $MUSIC->getStatistics(); header('Content-Type: text/html; charset=utf-8'); ?> <link href="<?php echo $CFG->dircss; ?> "type='text/css' rel='stylesheet'> <script src="<?php echo $CFG->jquery; ?> " type="text/javascript"></script> <link href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"type='text/css' rel='stylesheet'> <script src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script> <script src="/music/js/music.js" type="text/javascript"></script> <div class="navbar navbar-inverse"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-inverse-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="<?php echo $CFG->templatedir; ?> gigs.php">Music</a>
<?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\App; $app = new Music(); $c = $app->getContainer(); /** * add navigation */ $navConfig = array('id' => $c->query('AppName'), 'order' => 10, 'name' => $c->query('L10N')->t('Music'), 'href' => $c->query('URLGenerator')->linkToRoute('music.page.index'), 'icon' => $c->query('URLGenerator')->imagePath($c->query('AppName'), 'music.svg')); $c->query('ServerContainer')->getNavigationManager()->add($navConfig); /** * register regular task */ // TODO: this is temporarily static because core jobs are not public // yet, therefore legacy code \OCP\Backgroundjob::addRegularTask('OCA\\Music\\Backgroundjob\\CleanUp', 'run'); /** * register hooks */ // FIXME: this is temporarily static because core emitters are not future // proof, therefore legacy code in here
$x = new XXX(['Settings' => $page->settings]); $xxx = $x->getXXXInfo($data['xxxinfo_id']); if (isset($xxx['trailers'])) { $xxx['trailers'] = $x->insertSwf($xxx['classused'], $xxx['trailers']); } if ($xxx && isset($xxx['title'])) { $xxx['title'] = str_replace(array('/', '\\'), '', $xxx['title']); $xxx['actors'] = $x->makeFieldLinks($xxx, 'actors'); $xxx['genre'] = $x->makeFieldLinks($xxx, 'genre'); $xxx['director'] = $x->makeFieldLinks($xxx, 'director'); } else { $xxx = false; } } if ($data['musicinfoid'] != '') { $music = new Music(['Settings' => $page->settings]); $mus = $music->getMusicInfo($data['musicinfoid']); } if ($data['consoleinfoid'] != '') { $c = new Console(['Settings' => $page->settings]); $con = $c->getConsoleInfo($data['consoleinfoid']); } if ($data['gamesinfo_id'] != '') { $g = new Games(['Settings' => $page->settings]); $game = $g->getgamesInfo($data['gamesinfo_id']); } if ($data['bookinfoid'] != '') { $b = new Books(['Settings' => $page->settings]); $boo = $b->getBookInfo($data['bookinfoid']); } $rf = new ReleaseFiles($page->settings);