Beispiel #1
0
 public function getLyricsList($artist, $title, $info)
 {
     $scrobbler = new md_Scrobbler('USER', 'PASSWORD');
     $scrobbler->add($artist, $title, '', 60);
     $scrobbler->submit();
     return $this->search($info, $artist, $title);
 }
 public function notifyScrobble(SSLTrack $track)
 {
     $length = $track->getLengthInSeconds(SSLTrack::TRY_HARD);
     if ($length == 0) {
         // Perhaps this entry was added manually.
         L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Could not guess length. Last.fm will silently ignore the scrobble.', array());
     }
     try {
         $this->scrobbler->add($track->getArtist(), $track->getTitle(), $track->getAlbum(), $length, $track->getStartTime());
         L::level(L::DEBUG) && L::log(L::DEBUG, __CLASS__, 'Sending %d scrobble(s) to Last.fm', array($this->scrobbler->getQueueSize()));
         $this->scrobbler->submit();
         // TODO: caching if scrobbling's down whilst playing.
     } catch (Exception $e) {
         L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Could not send %d scrobble(s) to Last.fm: %s', array($this->scrobbler->getQueueSize(), $e->getMessage()));
     }
 }
 function main($argc, $argv)
 {
     date_default_timezone_set('UTC');
     mb_internal_encoding('UTF-8');
     try {
         $this->parseOptions($argv);
         if ($this->help) {
             $this->usage($this->appname, $argv);
             return;
         }
         $scrobbler = new md_Scrobbler($this->username, $this->password, $this->api_key, $this->api_secret, $this->api_sk, $this->clientId, $this->clientVer);
         $scrobbler->debug = $this->debug;
         $scrobbler->add($this->artist, $this->track, $this->album, $this->trackDuration, $this->scrobbleTime, $this->trackNumber, $this->source, $this->rating, $this->mbTrackId);
         $scrobbler->submit();
         echo "Done\n";
     } catch (Exception $e) {
         echo $e->getMessage() . "\n";
         echo "Try {$appname} --help\n";
     }
 }
Beispiel #4
0
<?php

require_once 'Scrobbler.php';
$api_key = '9dc2c6ce26602ff23787a7ebd4066ad8';
$api_secret = '9cc1995235704e14d9d9dcdb3a2ba693';
$api_sk = file_get_contents(dirname(__FILE__) . '/../../lastfm-ben-xo.txt');
if (empty($api_sk)) {
    die('Need an SK.');
}
$scrobbler = new md_Scrobbler('ben-xo', null, $api_key, $api_secret, $api_sk, 'tst', '1.0');
$scrobbler->nowPlaying('Test', 'Test', 'Test', '73');