From 4adf66c318da2663f4eb097781a828ad0a064760 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 21 Dec 2019 22:57:34 +1100 Subject: [PATCH] Minor fixes --- app/Console/Commands/VideoImport.php | 56 +++++++++---------- app/Console/Commands/VideoScanAll.php | 2 +- app/Models/Abstracted/Catalog.php | 3 +- app/Models/Photo.php | 1 - app/Models/Video.php | 11 ++-- .../views/photo/widgets/thumbnail.blade.php | 2 +- resources/views/video/view.blade.php | 4 +- 7 files changed, 40 insertions(+), 39 deletions(-) diff --git a/app/Console/Commands/VideoImport.php b/app/Console/Commands/VideoImport.php index 6a1e9c2..39ab822 100644 --- a/app/Console/Commands/VideoImport.php +++ b/app/Console/Commands/VideoImport.php @@ -13,12 +13,12 @@ class VideoImport extends Command use DispatchesJobs; use Files; - /** - * The name and signature of the console command. - * - * @var string - */ - protected $signature = 'video:import + /** + * The name and signature of the console command. + * + * @var string + */ + protected $signature = 'video:import {--dir= : Directory to Parse} {--file= : File to Import} {--ignoredupe : Ignore duplicate files} @@ -27,28 +27,28 @@ class VideoImport extends Command {--people= : People to reference in video} {--tags= : Add tag to video}'; - /** - * The console command description. - * - * @var string - */ - protected $description = 'Import videos into the database'; + /** + * The console command description. + * + * @var string + */ + protected $description = 'Import videos into the database'; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } + /** + * Create a new command instance. + * + * @return void + */ + public function __construct() + { + parent::__construct(); + } - /** - * Execute the console command. - * - * @return mixed - */ + /** + * Execute the console command. + * + * @return mixed + */ public function handle() { $files = $this->getFiles([ @@ -139,11 +139,11 @@ class VideoImport extends Command $this->dispatch((new \App\Jobs\CatalogScan($o))->onQueue('scan')); if ($this->option('dumpid3')) - dd($o->dump()); + dd($o->properties()); } $bar->finish(); return $this->info(sprintf('Videos processed: %s',$c)); } -} +} \ No newline at end of file diff --git a/app/Console/Commands/VideoScanAll.php b/app/Console/Commands/VideoScanAll.php index 9098d75..294716d 100644 --- a/app/Console/Commands/VideoScanAll.php +++ b/app/Console/Commands/VideoScanAll.php @@ -19,7 +19,7 @@ class VideoScanAll extends Command * @var string */ protected $signature = 'video:scanall'. - '{--scanned : Rescan Scanned Videos}'; + ' {--scanned : Rescan Scanned Videos}'; /** * The console command description. diff --git a/app/Models/Abstracted/Catalog.php b/app/Models/Abstracted/Catalog.php index 0c8b9b5..df5fbd9 100644 --- a/app/Models/Abstracted/Catalog.php +++ b/app/Models/Abstracted/Catalog.php @@ -155,7 +155,6 @@ abstract class Catalog extends Model /** * Determine the new name for the image - * @todo Make Generic for Photo and Video */ public function file_path($short=FALSE,$new=FALSE) { @@ -229,7 +228,7 @@ abstract class Catalog extends Model } public function getDateCreatedAttribute() { - return Carbon::createFromTimestamp($this->attributes['date_created']); + return $this->attributes['date_created'] ? Carbon::createFromTimestamp($this->attributes['date_created']) : NULL; } /** diff --git a/app/Models/Photo.php b/app/Models/Photo.php index bbd2530..2dca845 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -42,7 +42,6 @@ class Photo extends Abstracted\Catalog /** * Determine the new name for the image - * @todo Implement in Parent */ public function file_path($short=FALSE,$new=FALSE) { diff --git a/app/Models/Video.php b/app/Models/Video.php index 91cc6e8..639ec3f 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -2,7 +2,6 @@ namespace App\Models; -use DB; use Illuminate\Support\Arr; class Video extends Abstracted\Catalog @@ -31,6 +30,11 @@ class Video extends Abstracted\Catalog if (is_null($this->_o)) { + /* + * @todo There is a bug with getID3, where the second iteration yields different results + * this is problematic when video:scanall is run from a queue and there is more than 1 job. + * It also appears that only 1.9.18 gets date/gps data, a later version doesnt get gps data. + */ $this->_o = new \getID3; $this->_o->analyze($this->file_path()); $this->_o->getHashdata('sha1'); @@ -122,8 +126,7 @@ class Video extends Abstracted\Catalog public function setDateCreated() { - if ($this->property('creationdate')) - $this->date_created = $this->property('creationdate'); + $this->date_created = $this->property('creationdate'); } public function setDateCreatedAttribute($value) @@ -145,7 +148,7 @@ class Video extends Abstracted\Catalog $this->model = $this->property('model'); $this->software = $this->property('software'); $this->type = $this->property('type'); - $this->length = $this->property('length'); + $this->length = round($this->property('length'),2); $this->codec = $this->property('codec'); $this->audiochannels = $this->property('audiochannels'); $this->channelmode = $this->property('channelmode'); diff --git a/resources/views/photo/widgets/thumbnail.blade.php b/resources/views/photo/widgets/thumbnail.blade.php index 302e290..786f573 100644 --- a/resources/views/photo/widgets/thumbnail.blade.php +++ b/resources/views/photo/widgets/thumbnail.blade.php @@ -15,7 +15,7 @@
#{{ $o->id }} - {{ \Illuminate\Support\Str::limit($o->filename,12).\Illuminate\Support\Str::substr($o->filename,-16) }} - {{ $o->date_created->toDateTimeString() }} [{{ $o->device() }}] + {{ $o->date_created ? $o->date_created->toDateTimeString() : '-' }} [{{ $o->device() }}]
diff --git a/resources/views/video/view.blade.php b/resources/views/video/view.blade.php index 6df9280..ed0d2b3 100644 --- a/resources/views/video/view.blade.php +++ b/resources/views/video/view.blade.php @@ -25,13 +25,13 @@