public function run()
 {
     spl_autoload_register(array('Core', 'autoload'), true, true);
     Requests::register_autoloader();
     if ($this->song_info) {
         User::save_songplay($this->user, $this->song_info);
     }
 }
Example #2
0
 /**
  * update_user_stats
  * updates the playcount mojo for this specific user
  */
 public function update_stats($song_id, $agent = '')
 {
     debug_event('user.class.php', 'Updating stats for {' . $song_id . '} {' . $agent . '}...', '5');
     $song_info = new Song($song_id);
     $song_info->format();
     $user = $this->id;
     if (!strlen($song_info->file)) {
         return false;
     }
     $this->set_preferences();
     // If pthreads available, we call save_songplay in a new thread to quickly return
     if (class_exists("Thread", false)) {
         debug_event('user.class.php', 'Calling save_songplay plugins in a new thread...', '5');
         $thread = new scrobbler_async($GLOBALS['user'], $song_info);
         if ($thread->start()) {
             //$thread->join();
         } else {
             debug_event('user.class.php', 'Error when starting the thread.', '1');
         }
     } else {
         User::save_songplay($GLOBALS['user'], $song_info);
     }
     // Do this last so the 'last played checks are correct'
     Stats::insert('song', $song_id, $user, $agent);
     Stats::insert('album', $song_info->album, $user, $agent);
     Stats::insert('artist', $song_info->artist, $user, $agent);
     return true;
 }