public function tracksAction() { $this->doNotRender(); $centova_tracks = CentovaCast::fetchTracks($this->station); if (empty($centova_tracks)) { throw new \DF\Exception\DisplayOnly('Track list could not be loaded from CentovaCast.'); } \DF\Export::csv($centova_tracks, false, $this->station->getShortName() . '_tracks_' . date('Ymd')); }
public function testAction() { $this->doNotRender(); set_time_limit(0); ini_set('memory_limit', '-1'); Debug::setEchoMode(); // -------- START HERE -------- // \PVL\CentovaCast::sync(); Debug::log('CCast Sync Complete'); $station = \Entity\Station::getRepository()->findOneBy(array('name' => 'PonyvilleFM')); $tracks = \PVL\CentovaCast::fetchTracks($station); Debug::print_r($tracks); // -------- END HERE -------- // Debug::log('Done!'); }
public static function syncMedium($force = false) { self::initSync(300); // Sync schedules (highest priority). Debug::runTimer('Run schedule manager', function () { ScheduleManager::run(!DF_IS_COMMAND_LINE); }); // Sync show episodes and artist news (high priority). Debug::runTimer('Run podcast manager', function () { PodcastManager::run(); }); // Pull the homepage news. Debug::runTimer('Run network news manager', function () { NewsManager::run(); }); // Sync CentovaCast song data. Debug::runTimer('Run CentovaCast track sync', function () { CentovaCast::sync(); }); Settings::setSetting('sync_last_run', time()); }
public function requestAction() { $this->stationRequired(); if (!$this->station->requests_enabled) { throw new \DF\Exception\DisplayOnly('This station does not support requests at this time.'); } if ($this->station->requests_external_url) { return $this->redirect($this->station->requests_external_url); } $is_supported = CentovaCast::isStationSupported($this->station); if (!$is_supported) { throw new \DF\Exception\DisplayOnly('This station is not functioning properly and cannot accept requests at this time.'); } // Search redirection. if ($_GET) { $this->redirectFromHere($_GET); } // Process a request. if ($this->getParam('track')) { try { $track_id = (int) $this->getParam('track'); CentovaCast::request($this->station, $track_id); $track = StationMedia::find($track_id); $this->alert('<b>Your song, "' . $track->title . '" by ' . $track->artist . ', has been requested.</b><br>Stay tuned to the station to hear it!', 'green'); } catch (\DF\Exception $e) { $this->alert('<b>Your song could not be requested. An error occurred:</b><br>' . $e->getMessage(), 'red'); } $this->redirectFromHere(array('track' => NULL)); return; } // Most requested songs. $top_songs = $this->em->createQuery('SELECT sm FROM Entity\\StationMedia sm WHERE sm.station_id = :station_id AND sm.requests > 0 ORDER BY sm.requests DESC')->setParameter('station_id', $this->station_id)->setMaxResults(10)->getArrayResult(); $this->view->top_songs = $top_songs; // Artist names. $artist_names_raw = $this->em->createQuery('SELECT DISTINCT sm.artist FROM Entity\\StationMedia sm WHERE sm.station_id = :station_id ORDER BY sm.artist ASC')->setParameter('station_id', $this->station_id)->getArrayResult(); $artist_names = array(); foreach ($artist_names_raw as $name) { $artist_names[] = $name['artist']; } $this->view->artist_names = $artist_names; // Paginated results. if ($this->hasParam('q')) { $query = $this->getParam('q'); $media = StationMedia::search($this->station, $query); $this->view->page_title = 'Search Results for "' . htmlspecialchars($query) . '"'; $this->view->reset_button = true; } else { if ($this->hasParam('artist')) { $artist = $this->getParam('artist'); $media = StationMedia::getByArtist($this->station, $artist); $this->view->page_title = 'All Songs by ' . htmlspecialchars($artist); $this->view->reset_button = true; } else { $media = StationMedia::getRequestable($this->station); $this->view->page_title = 'All Available Songs'; $this->view->reset_button = false; } } $pager = new \DF\Paginator($media, $this->getParam('page'), 50); $this->view->pager = $pager; }