function SERVICE_REPORTING_audioscrobbler($node) { global $jzUSER, $enable_audioscrobbler, $as_override_user, $as_override_pass, $as_override_all; // First is audioscrobbler enabled? if ($enable_audioscrobbler != "true") { return; } writeLogData("as_debug", "AudioScrobbler: Starting up (inside startup routine) "); // Let's get the meta data from the track $meta = $node->getMeta(); $timestamp = $node->getStartTime(); // Now let's get the user info if ($as_override_user != "" and $as_override_all == "true") { $user = $as_override_user; $pass = $as_override_pass; } else { $user = $jzUSER->getSetting("asuser"); $pass = $jzUSER->getSetting("aspass"); if ($user == false and $as_override_user != "") { $user = $as_override_user; $pass = $as_override_pass; } } if ($user == "") { return; } writeLogData("as_debug", "AudioScrobbler: Sending data for user: "******"as_debug", "AudioScrobbler: Sending data for user: "******"as_debug", "AudioScrobbler: Sending previously queued tracks"); if (!$as->submitTracks()) { writeLogData("messages", 'AudioScrobbler->submitTracks Error, will retry later: ' . $as->errorMsg); writeLogData("as_debug", 'AudioScrobbler->submitTracks Error, will retry later: ' . $as->errorMsg); } } else { writeLogData("messages", 'AudioScrobbler->handshake: Error, retry later: ' . $as->errorMsg); writeLogData("as_debug", 'AudioScrobbler->handshake: Error, retry later: ' . $as->errorMsg); return; } // Gotta make sure it's at least 31 seconds long $length = $meta['length']; if ($length < 30) { $length = 31; if ($length < 30) { writeLogData("messages", "AudioScrobbler: Warning: Track length less than 30 seconds. Not submitting"); writeLogData("as_debug", "AudioScrobbler: Warning: Track length less than 30 seconds. Not submitting"); return; } } // Now queue current track writeLogData("as_debug", "AudioScrobbler: Queueing data for: " . $meta['title']); if (empty($timestamp)) { $timestamp = time(); } $as->queueTrack($meta['artist'], $meta['album'], $meta['title'], $timestamp, $length); writeLogData("as_debug", "AudioScrobbler: Sending data complete"); }
<?php require_once 'init.php'; if (isset($_GET['user']) && isset($_GET['macs'])) { $aRecentData = (array) $oCall->call('user.getRecentTracks', array('user' => $_GET['user'])); $aLast = (array) $aRecentData['track'][0]; $aMacs = explode(',', $_GET['macs']); foreach ($aMacs as $mac) { $aUser = $oSession->getUserByMac($mac); if ($aUser) { $oScrob = new Scrobbler($aUser['name'], $aUser['key'], $oCall->getApiKey(), $oCall->getApiSecret()); $oScrob->scrobble($aLast['artist'], $aLast['name'], strtotime($aLast['date'])); } } } print "OK";