Esempio n. 1
0
     $sql = "SELECT * FROM grammafone_audioscrobbler WHERE user_id=" . $_SERVER['argv'][1];
     $wait = 60;
     $success = FALSE;
     while (!$success && $wait <= 7200) {
         $result = mysql_query($sql);
         $songs = array();
         if (mysql_num_rows($result) > 0) {
             $now = time();
             while ($row = mysql_fetch_array($result)) {
                 $song = getSongInfo($row['song_id']);
                 $songs[] = $row['as_id'];
                 if ($song['length'] > 30) {
                     $as->queueTrack($song['artist_name'], $song['album_name'], $song['name'], $row['as_timestamp'], $song['length']);
                 }
             }
             if ($as->submitTracks()) {
                 //echo "Submit Success\n";
                 $success = TRUE;
                 $songs_sql = implode(" OR as_id=", $songs);
                 $sql = "DELETE FROM grammafone_audioscrobbler WHERE as_id={$songs_sql}";
                 mysql_query($sql);
                 updateScrobblerResult($_SERVER['argv'][1], "Successfully submitted " . count($songs) . " songs to AudioScrobbler");
             } else {
                 //echo "Submit Failed (waiting $wait seconds): ".$as->getErrorMsg()."\n";
                 updateScrobblerResult($_SERVER['argv'][1], "Submit Failed: " . $as->getErrorMsg());
                 sleep($wait);
                 $wait = $wait * 2;
             }
         }
     }
 }