diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/batch.lib.php | 1 | ||||
-rw-r--r-- | lib/class/user.class.php | 22 | ||||
-rw-r--r-- | lib/init.php | 2 |
3 files changed, 23 insertions, 2 deletions
diff --git a/lib/batch.lib.php b/lib/batch.lib.php index 867956a9..6666cbb1 100644 --- a/lib/batch.lib.php +++ b/lib/batch.lib.php @@ -34,7 +34,6 @@ function get_song_files( $song_ids ) { $song = new Song( $song_id ); /* Don't archive disabled songs */ if ($song->status != 'disabled') { - $user->update_stats( $song_id ); $total_size += sprintf("%.2f",($song->size/1048576)); array_push( $song_files, $song->file ); } // if song isn't disabled diff --git a/lib/class/user.class.php b/lib/class/user.class.php index fefca81f..46ebf4e4 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -433,7 +433,6 @@ class User { $song_info = new Song($song_id); //FIXME:: User uid reference $user = $this->uid; - if (!$song_info->file) { return false; } $stats = new Stats(); @@ -442,6 +441,27 @@ class User { $stats->insert('artist',$song_info->artist,$user); $stats->insert('genre',$song_info->genre,$user); + /* Record this play to LastFM */ + if ($this->prefs['lastfm_user'] AND $this->prefs['lastfm_pass']) { + $song_info->format_song(); + $lastfm = new scrobbler($this->prefs['lastfm_user'],$this->prefs['lastfm_pass']); + /* Attempt handshake */ + if ($lastfm->handshake()) { + if (!$lastfm->queue_track($song_info->f_artist_full,$song_info->f_album_full,$song_info->title,time(),$song_info->time)) { + debug_event('LastFM','Error: Queue Failed' . $lastfm->error_msg,'3'); + } + if (!$lastfm->submit_tracks()) { + debug_event('LastFM','Error Submit Failed' . $lastfm->error_msg,'3'); + } + } // if handshake + else { + debug_event('LastFM','Error: Handshake failed with LastFM:' . $lastfm->error_msg,'3'); + } + } // record to LastFM + else { + debug_event('plugins','Error: No Prefs','3'); + } + } // update_stats /** diff --git a/lib/init.php b/lib/init.php index d645f0ae..72809b14 100644 --- a/lib/init.php +++ b/lib/init.php @@ -190,6 +190,8 @@ require_once(conf('prefix') . '/lib/class/access.class.php'); require_once(conf('prefix') . '/lib/class/error.class.php'); require_once(conf('prefix') . '/lib/class/genre.class.php'); require_once(conf('prefix') . '/lib/class/flag.class.php'); +require_once(conf('prefix') . '/lib/class/audioscrobbler.class.php'); + /* Set a new Error Handler */ $old_error_handler = set_error_handler("ampache_error_handler"); |