Updates for Videos
This commit is contained in:
@@ -6,9 +6,6 @@ use Illuminate\Console\Command;
|
||||
|
||||
class CatalogScan extends Command
|
||||
{
|
||||
// Our photo object
|
||||
private $o = NULL;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
@@ -72,8 +69,10 @@ class CatalogScan extends Command
|
||||
|
||||
$o->scanned = '1';
|
||||
|
||||
if ($o->getDirty())
|
||||
if ($o->getDirty()) {
|
||||
$this->warn(sprintf('Image [%s] metadata changed',$o->file_path()));
|
||||
//dump($o->getDirty());
|
||||
}
|
||||
|
||||
$o->save();
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
|
@@ -2,17 +2,16 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Log;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use App\Model\Video;
|
||||
use App\Model\Tag;
|
||||
use App\Model\Person;
|
||||
|
||||
use App\Models\{Person,Video,Tag};
|
||||
use App\Traits\Files;
|
||||
|
||||
class VideoImport extends Command
|
||||
{
|
||||
use DispatchesJobs;
|
||||
use \App\Traits\Files;
|
||||
use Files;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@@ -52,7 +51,11 @@ class VideoImport extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$files = $this->getFiles(['dir'=>$this->option('dir'),'file'=>$this->option('file')],'video');
|
||||
$files = $this->getFiles([
|
||||
'dir'=>$this->option('dir'),
|
||||
'file'=>$this->option('file')
|
||||
],'video');
|
||||
|
||||
if (! count($files))
|
||||
exit;
|
||||
|
||||
@@ -64,22 +67,21 @@ class VideoImport extends Command
|
||||
$t = $p = array();
|
||||
|
||||
// Tags
|
||||
if ($this->option('tags'))
|
||||
{
|
||||
if ($this->option('tags')) {
|
||||
$tags = explode(',',$this->option('tags'));
|
||||
$t = Tag::whereIn('tag',$tags)->pluck('id')->toArray();
|
||||
if (! $t OR count($t) != count($tags))
|
||||
{
|
||||
|
||||
if (! $t OR count($t) != count($tags)) {
|
||||
$this->error(sprintf('Tag [%s] dont exist',join('|',$tags)));
|
||||
abort(501);
|
||||
}
|
||||
}
|
||||
|
||||
// People
|
||||
if ($this->option('people'))
|
||||
{
|
||||
if ($this->option('people')) {
|
||||
$tags = explode(',',$this->option('people'));
|
||||
$p = Person::whereIn('tag',$tags)->pluck('id')->toArray();
|
||||
|
||||
if (! $p OR count($p) != count($tags))
|
||||
{
|
||||
$this->error(sprintf('People [%s] dont exist',join('|',$tags)));
|
||||
@@ -88,18 +90,15 @@ class VideoImport extends Command
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
foreach ($files as $file)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$bar->advance();
|
||||
|
||||
if (preg_match('/@__thumb/',$file) OR preg_match('/\/._/',$file))
|
||||
{
|
||||
if (preg_match('/@__thumb/',$file) OR preg_match('/\/._/',$file)) {
|
||||
$this->warn(sprintf('Ignoring file [%s]',$file));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)),config('video.import.accepted')))
|
||||
{
|
||||
if (! in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)),config('video.import.accepted'))) {
|
||||
$this->warn(sprintf('Ignoring [%s]',$file));
|
||||
continue;
|
||||
}
|
||||
@@ -111,21 +110,21 @@ class VideoImport extends Command
|
||||
|
||||
$o = Video::where('filename',$file)->first();
|
||||
|
||||
if (is_null($o))
|
||||
{
|
||||
// The video doesnt exist
|
||||
if (is_null($o)) {
|
||||
$o = new Video;
|
||||
$o->filename = $file;
|
||||
}
|
||||
|
||||
if (! is_readable($o->file_path()))
|
||||
{
|
||||
if ($o->exists)
|
||||
$this->warn(sprintf('%s [%s] already in DB: %s',$o->objectType(),$file,$o->id));
|
||||
|
||||
// Make sure we can read the video.
|
||||
if (! is_readable($o->file_path())) {
|
||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($o->exists)
|
||||
$this->warn(sprintf('%s [%s] already in DB: %s',$o->objectType(),$file,$o->id));
|
||||
|
||||
$o->save();
|
||||
|
||||
if ($o->wasRecentlyCreated)
|
||||
|
Reference in New Issue
Block a user