getFullTitle() публичный Метод

public getFullTitle ( )
 public function elapse($seconds)
 {
     $this->playtime += $seconds;
     $was_passed_now_playing_point = $this->passed_now_playing_point;
     $was_passed_scrobble_point = $this->passed_scrobble_point;
     $was_ended = $this->passed_end;
     $this->passed_now_playing_point = $this->playtime >= self::NOW_PLAYING_MIN;
     $this->passed_scrobble_point = $this->playtime >= $this->scrobble_point;
     $this->passed_end = $this->playtime >= $this->end_point;
     if ($this->passed_now_playing_point && !$was_passed_now_playing_point) {
         L::level(L::INFO) && L::log(L::INFO, __CLASS__, '%s passed now playing point', array($this->track->getFullTitle()));
     }
     if ($this->passed_scrobble_point && !$was_passed_scrobble_point) {
         L::level(L::INFO) && L::log(L::INFO, __CLASS__, '%s passed scrobble point', array($this->track->getFullTitle()));
     }
     if ($this->passed_end && !$was_ended) {
         L::level(L::INFO) && L::log(L::INFO, __CLASS__, '%s passed end point', array($this->track->getFullTitle()));
     }
 }
Пример #2
0
 public function notifyNowPlaying(SSLTrack $track = null)
 {
     if (!$track) {
         return;
     }
     $sock = fsockopen($this->host, $this->port, $errno, $errstr, $timeout = 1);
     if ($sock === false) {
         L::level(L::ERROR) && L::log(L::ERROR, __CLASS__, "couldn't connect to IRCCat: (%d) %s", array($errno, $errstr));
         return;
     }
     $message = sprintf($this->config['message'], $track->getFullTitle());
     L::level(L::INFO) && L::log(L::INFO, __CLASS__, "sending '%s' -> %s:%d#%s", array($message, $this->host, $this->port, $this->channel));
     fwrite($sock, sprintf("%s %s", $this->channel, $message));
     fclose($sock);
 }
 protected function getBeatportURL(SSLTrack $track)
 {
     $url = '';
     $bp = $this->newBeatportAPIClient();
     $artistName = $track->getArtist();
     $trackName = $track->getTitle();
     $bp_track = $bp->getTrackByArtist($artistName, $trackName);
     if ($bp_track) {
         $bp_artist_names = $bp_track->getArtistNames();
         $bp_track_title = $bp_track->getName();
         $bp_url = $bp_track->getURL();
         $bp_track_string = implode(', ', $bp_artist_names) . ' - ' . $bp_track_title;
         $ssl_track_string = $track->getFullTitle();
         L::level(L::INFO) && L::log(L::INFO, __CLASS__, "Found %s at %s", array($bp_track_string, $bp_url));
         if ($this->checkMatch($ssl_track_string, $bp_track_string)) {
             $url = $bp_track->getURL();
         } else {
             L::level(L::INFO) && L::log(L::INFO, __CLASS__, "Rejected %s as a match for %s", array($bp_track_string, $ssl_track_string));
         }
     } else {
         L::level(L::INFO) && L::log(L::INFO, __CLASS__, "No track found.", array());
     }
     return $url;
 }
Пример #4
0
 /**
  * It's an SQL error to provide the wrong number variable bindings to a prepared
  * statement, so we must trim down the number we pass based on which actually
  * appeared in the SQL statement.
  */
 protected function getPlaceholdersFromTrack(SSLTrack $track, array $placeholder_map)
 {
     $placeholders = array();
     if ($placeholder_map[':track']) {
         $placeholders[':track'] = $track->getFullTitle();
     }
     if ($placeholder_map[':artist']) {
         $placeholders[':artist'] = $track->getArtist();
     }
     if ($placeholder_map[':title']) {
         $placeholders[':title'] = $track->getTitle();
     }
     if ($placeholder_map[':album']) {
         $placeholders[':album'] = $track->getAlbum();
     }
     if ($placeholder_map[':key']) {
         $placeholders[':key'] = $this->key;
     }
     return $placeholders;
 }
Пример #5
0
 protected function getBestTrack(SSLTrack $track)
 {
     $search = $this->doMixcloudCall('best track', 'http://api.mixcloud.com/search/?q=%s+%s&type=track', array(urlencode($track->getArtist()), urlencode($track->getTitle())));
     if (isset($search['error'])) {
         throw new Exception('Error from Mixcloud: ' . $search['error']['message']);
     }
     $potential_tracks = array();
     foreach ($search['data'] as $result) {
         $potential_track = array('artist' => $result['artist']['name'], 'title' => $result['name'], 'key' => $result['key']);
         $score = levenshtein($track->getArtist() . ' ' . $track->getTitle(), $result['artist']['name'] . ' ' . $result['name']);
         $potential_tracks[$score] = $result['key'];
     }
     if ($potential_tracks) {
         ksort($potential_tracks);
         $best_track = array_shift($potential_tracks);
         L::level(L::INFO) && L::log(L::INFO, __CLASS__, 'Best track match: %s', array($best_track));
         return $best_track;
     }
     throw new Exception('no track match for ' . $track->getFullTitle());
 }
 public function notifyScrobble(SSLTrack $track)
 {
     $this->growler->notify('alert', 'Scrobbling', $track->getFullTitle());
     L::level(L::INFO) && L::log(L::INFO, __CLASS__, '>> Scrobbling: >> %s', array($track->getFullTitle()));
 }
Пример #7
0
 protected function stopTrack(SSLTrack $stopped_track)
 {
     $stopped_row = $stopped_track->getRow();
     foreach ($this->now_playing_queue as $i => $scrobble_model) {
         /* @var $scrobble_model ScrobblerTrackModel */
         if ($scrobble_model->getRow() == $stopped_row) {
             // remove from the queue.
             unset($this->now_playing_queue[$i]);
             // remove from now_playing, if necessary.
             if ($this->now_playing_in_queue && $this->now_playing_in_queue->getRow() == $stopped_row) {
                 $this->now_playing_in_queue = null;
             }
             break;
         }
     }
     // reindex the queue
     $this->now_playing_queue = array_merge($this->now_playing_queue);
     L::level(L::INFO) && L::log(L::INFO, __CLASS__, 'dequeued track %s', array($stopped_track->getFullTitle()));
     L::level(L::DEBUG) && L::log(L::DEBUG, __CLASS__, 'queue length is now %d', array(count($this->now_playing_queue)));
 }