summaryrefslogtreecommitdiffstats
path: root/lib/class/user.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-12 21:58:26 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-12 21:58:26 +0000
commit504cd93ea89844219a1642a9acdb5797a3e303c1 (patch)
treee11717d39060baeb0e77bd7c3ac485c5cf3569c6 /lib/class/user.class.php
parent4feee9e40a198046a87be105d70caea6b6a9fb6f (diff)
downloadampache-504cd93ea89844219a1642a9acdb5797a3e303c1.tar.gz
ampache-504cd93ea89844219a1642a9acdb5797a3e303c1.tar.bz2
ampache-504cd93ea89844219a1642a9acdb5797a3e303c1.zip
typos abound!
Diffstat (limited to 'lib/class/user.class.php')
-rw-r--r--lib/class/user.class.php38
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index fefca81f..14fa4abc 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -433,7 +433,7 @@ 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 +442,42 @@ class User {
$stats->insert('artist',$song_info->artist,$user);
$stats->insert('genre',$song_info->genre,$user);
+ /**
+ * Record this play to LastFM
+ * because it lags like the dickens try twice on everything
+ */
+ 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 */
+ $handshake = $lastfm->handshake();
+
+ /* We failed, try again */
+ if (!$handshake) { sleep(1); $handshake = $lastfm->handshake(); }
+
+
+ if ($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');
+ }
+
+ $submit = $lastfm->submit_tracks();
+
+ /* Try again if it fails */
+ if (!$submit) { sleep(1); $submit = $lastfm->submit_tracks(); }
+
+ if (!$submit) {
+ 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
/**