Example #1
0
 public function run()
 {
     spl_autoload_register(array('Core', 'autoload'), true, true);
     Requests::register_autoloader();
     if ($this->song_info) {
         User::save_mediaplay($this->user, $this->song_info);
     }
 }
Example #2
0
 /**
  * update_user_stats
  * updates the playcount mojo for this specific user
  */
 public function update_stats($media_type, $media_id, $agent = '', $location = array(), $noscrobble = false)
 {
     debug_event('user.class.php', 'Updating stats for {' . $media_type . '/' . $media_id . '} {' . $agent . '}...', 5);
     $media = new $media_type($media_id);
     $media->format();
     $user = $this->id;
     // We shouldn't test on file only
     if (!strlen($media->file)) {
         return false;
     }
     if (!$noscrobble) {
         $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_mediaplay plugins in a new thread...', 5);
             $thread = new scrobbler_async($GLOBALS['user'], $media);
             if ($thread->start()) {
                 //$thread->join();
             } else {
                 debug_event('user.class.php', 'Error when starting the thread.', 1);
             }
         } else {
             User::save_mediaplay($GLOBALS['user'], $media);
         }
     } else {
         debug_event('user.class.php', 'Scrobbling explicitly skipped', 5);
     }
     $media->set_played($user, $agent, $location);
     return true;
 }