summaryrefslogtreecommitdiffstats
path: root/contrib/plugins/Last.FM
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-06 08:49:59 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-06 08:49:59 +0000
commit708bb80c7ab181cc439e8a91eb49d0eae282d3c6 (patch)
tree3e82f2023f263f7195b47cda4b64d18c947dd91b /contrib/plugins/Last.FM
parent3af41d1ac325312c1ed250621cea8e95b7d8591f (diff)
downloadampache-708bb80c7ab181cc439e8a91eb49d0eae282d3c6.tar.gz
ampache-708bb80c7ab181cc439e8a91eb49d0eae282d3c6.tar.bz2
ampache-708bb80c7ab181cc439e8a91eb49d0eae282d3c6.zip
fixed issue with audioscrobbler class
Diffstat (limited to 'contrib/plugins/Last.FM')
-rw-r--r--contrib/plugins/Last.FM/Lastfm.patch60
1 files changed, 39 insertions, 21 deletions
diff --git a/contrib/plugins/Last.FM/Lastfm.patch b/contrib/plugins/Last.FM/Lastfm.patch
index fa383e0c..7b818705 100644
--- a/contrib/plugins/Last.FM/Lastfm.patch
+++ b/contrib/plugins/Last.FM/Lastfm.patch
@@ -1,7 +1,7 @@
-diff -Naur --exclude=.svn ampache.ref/lib/class/audioscrobbler.class.php ampache.dev/lib/class/audioscrobbler.class.php
---- ampache.ref/lib/class/audioscrobbler.class.php 1969-12-31 16:00:00.000000000 -0800
-+++ ampache.dev/lib/class/audioscrobbler.class.php 2006-11-26 14:01:23.000000000 -0800
-@@ -0,0 +1,210 @@
+diff -Nuar --exclude=.svn trunk/lib/class/audioscrobbler.class.php ampache/lib/class/audioscrobbler.class.php
+--- trunk/lib/class/audioscrobbler.class.php 1969-12-31 16:00:00.000000000 -0800
++++ ampache/lib/class/audioscrobbler.class.php 2006-12-06 00:24:18.000000000 -0800
+@@ -0,0 +1,212 @@
+<?php
+/*
+
@@ -78,7 +78,10 @@ diff -Naur --exclude=.svn ampache.ref/lib/class/audioscrobbler.class.php ampache
+ }
+
+ $username = rawurlencode($this->username);
-+ fwrite($as_socket, "GET /?hs=true&p=1.1&c=m3a&v=0.1&u=".$username." HTTP/1.1\r\n");
++
++ $get_string = "GET /?hs=true&p=1.1&c=m3a&v=0.1&u=$username HTTP/1.1\r\n";
++
++ fwrite($as_socket, $get_string);
+ fwrite($as_socket, "Host: post.audioscrobbler.com\r\n");
+ fwrite($as_socket, "Accept: */*\r\n\r\n");
+
@@ -87,15 +90,14 @@ diff -Naur --exclude=.svn ampache.ref/lib/class/audioscrobbler.class.php ampache
+ $buffer .= fread($as_socket, 8192);
+ }
+ fclose($as_socket);
-+
+ $split_response = preg_split("/\r\n\r\n/", $buffer);
+ if(!isset($split_response[1])) {
+ $this->error_msg = 'Did not receive a valid response';
+ return FALSE;
+ }
+ $response = explode("\n", $split_response[1]);
-+
-+ if(substr($response[0], 0, 6) == 'FAILED') {
++
++ if(substr($response[0], 0, 6) == 'FAILED') {
+ $this->error_msg = substr($response[0], 7);
+ return FALSE;
+ }
@@ -108,7 +110,7 @@ diff -Naur --exclude=.svn ampache.ref/lib/class/audioscrobbler.class.php ampache
+ return FALSE;
+ }
+
-+ if(preg_match('/http:\/\/(.*):(\d+)(.*)/', $response[2], $matches)) {
++ if(preg_match('/http:\/\/(.*):(\d+)(.*)/', $response[3], $matches)) {
+ $this->submit_host = $matches[1];
+ $this->submit_port = $matches[2];
+ $this->submit_url = $matches[3];
@@ -117,7 +119,7 @@ diff -Naur --exclude=.svn ampache.ref/lib/class/audioscrobbler.class.php ampache
+ return FALSE;
+ }
+
-+ $this->challenge = $response[1];
++ $this->challenge = $response[2];
+ return true;
+
+ } // handshake
@@ -212,10 +214,19 @@ diff -Naur --exclude=.svn ampache.ref/lib/class/audioscrobbler.class.php ampache
+
+}
+?>
-diff -Naur --exclude=.svn ampache.ref/lib/class/user.class.php ampache.dev/lib/class/user.class.php
---- ampache.ref/lib/class/user.class.php 2006-11-26 13:47:45.000000000 -0800
-+++ ampache.dev/lib/class/user.class.php 2006-11-26 14:01:51.000000000 -0800
-@@ -434,6 +434,20 @@
+diff -Nuar --exclude=.svn trunk/lib/class/user.class.php ampache/lib/class/user.class.php
+--- trunk/lib/class/user.class.php 2006-12-06 00:31:03.000000000 -0800
++++ ampache/lib/class/user.class.php 2006-12-05 23:32:24.000000000 -0800
+@@ -433,7 +433,7 @@
+ $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,27 @@
$stats->insert('artist',$song_info->artist,$user);
$stats->insert('genre',$song_info->genre,$user);
@@ -225,21 +236,28 @@ diff -Naur --exclude=.svn ampache.ref/lib/class/user.class.php ampache.dev/lib/c
+ $lastfm = new scrobbler($this->prefs['lastfm_user'],$this->prefs['lastfm_pass']);
+ /* Attempt handshake */
+ if ($lastfm->handshake()) {
-+ $lastfm->queue_track($song->f_artist_full,$song->f_album_full,$song->title,time(),$song->time);
-+ $lastfm->submit_tracks();
++ 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('plugins','Error: Handshake failed with LastFM','3');
++ 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 -Naur --exclude=.svn ampache.ref/lib/init.php ampache.dev/lib/init.php
---- ampache.ref/lib/init.php 2006-11-26 13:47:45.000000000 -0800
-+++ ampache.dev/lib/init.php 2006-11-26 14:02:14.000000000 -0800
-@@ -185,6 +185,8 @@
+diff -Nuar --exclude=.svn trunk/lib/init.php ampache/lib/init.php
+--- trunk/lib/init.php 2006-12-06 00:31:03.000000000 -0800
++++ ampache/lib/init.php 2006-12-05 23:32:24.000000000 -0800
+@@ -190,6 +190,8 @@
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');