Exemplo n.º 1
0
 /**
  * @Route("/uploadmanager", name="uploadmanager", methods="GET")
  */
 public function uploadManagerAction()
 {
     if ($this->requireLogin()) {
         return App::response()->redirect('@user/login');
     }
     $uploads = Media::where(['uploader_id = :uploader AND status != :finished'], ['uploader' => App::user()->id, 'finished' => Media::STATUS_FINISHED])->orderBy('created', 'DESC')->related(['artist', 'user'])->get();
     return ['$view' => ['title' => __('Upload Manager'), 'name' => 'shoutzor:views/uploadmanager.php'], 'uploads' => $uploads, 'maxFileSize' => $this->formatBytes($this->file_upload_max_size()), 'maxDuration' => App::module('shoutzor')->config('shoutzor')['uploadDurationLimit']];
 }
Exemplo n.º 2
0
 /**
  * Checks if the provided instance is unique
  * @return false|Music
  */
 public function exists(Media $media)
 {
     $obj = Media::where('crc = :crc AND status = :status', ['crc' => $media->crc, 'status' => Media::STATUS_FINISHED]);
     if ($obj->count() == 0) {
         return false;
     }
     return $obj->first();
 }
Exemplo n.º 3
0
 /**
  * Automatically parses music files that have not been parsed yet
  * @method autoparse
  */
 public function autoparse()
 {
     //Make sure it's the server that requested this method
     if ($this->ensureLocalhost() === false) {
         return $this->formatOutput(__('You have no access to this method'), self::METHOD_NOT_AVAILABLE);
     }
     //Get our configuration values
     $config = App::module('shoutzor')->config('shoutzor');
     $lastRun = $config['parserLastRun'];
     //Check if the last-run time was more then 1 minute ago to make sure no other parser processes are running
     if ($lastRun > strtotime("-1 minute")) {
         return $this->formatOutput(__('A parser is already running or has been running too recently'), self::ERROR_IN_REQUEST);
     }
     //Get a list of items that need to be parsed
     $toParse = Media::where(['status = :status'], ['status' => Media::STATUS_UPLOADED])->where(['status = :status'], ['status' => Media::STATUS_ERROR])->limit($config['parserMaxItems'])->get();
     //Parse each item
     foreach ($toParse as $item) {
         //Update the parserLastRun value to the current time
         App::config('shoutzor')->set('shoutzor', ['parserLastRun' => time()]);
         //Parse the item
         $this->parse(['id' => $item->id]);
     }
     //Return true
     return $this->formatOutput(true);
 }