Updates for Videos
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models\Abstracted;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use DB;
|
||||
@@ -108,7 +109,7 @@ abstract class Catalog extends Model
|
||||
*/
|
||||
public function date_taken(): string
|
||||
{
|
||||
return $this->date_created ? date('Y-m-d H:i:s',$this->date_created) : 'UNKNOWN';
|
||||
return $this->date_created ? $this->date_created->format('Y-m-d H:i:s') : 'UNKNOWN';
|
||||
}
|
||||
|
||||
public function device(): string
|
||||
@@ -163,7 +164,7 @@ abstract class Catalog extends Model
|
||||
if ($new)
|
||||
$file = sprintf('%s.%s',((is_null($this->date_created) OR ! $this->date_created)
|
||||
? sprintf('UNKNOWN/%07s',$this->file_path_id())
|
||||
: date('Y/m/d-His',$this->date_created)),$this->type());
|
||||
: $this->date_created->format('Y/m/d-His')),$this->type());
|
||||
|
||||
return (($short OR preg_match('/^\//',$file)) ? '' : config('video.dir').DIRECTORY_SEPARATOR).$file;
|
||||
}
|
||||
@@ -227,6 +228,10 @@ abstract class Catalog extends Model
|
||||
return $this->HTMLCheckbox('flag',$this->id,$this->flag);
|
||||
}
|
||||
|
||||
public function getDateCreatedAttribute() {
|
||||
return Carbon::createFromTimestamp($this->attributes['date_created']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@@ -337,6 +342,8 @@ abstract class Catalog extends Model
|
||||
->first();
|
||||
}
|
||||
|
||||
abstract public function property(string $property);
|
||||
|
||||
/**
|
||||
* Return my class shortname
|
||||
*/
|
||||
@@ -368,13 +375,12 @@ abstract class Catalog extends Model
|
||||
*/
|
||||
public function signature($short=FALSE)
|
||||
{
|
||||
return $short ? static::signaturetrim($this->signature) : $this->signature;
|
||||
return ($short AND $this->signature) ? static::stringtrim($this->signature) : $this->signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim a string
|
||||
*
|
||||
* @todo rename stringtrim
|
||||
* @param string $string
|
||||
* @param int $chrs
|
||||
* @return string
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Photo extends Abstracted\Catalog
|
||||
@@ -60,7 +59,7 @@ class Photo extends Abstracted\Catalog
|
||||
|
||||
public function getHtmlImageURL(): string
|
||||
{
|
||||
return sprintf('<img height="240" src="%s"></img>',url('/p/thumbnail/'.$this->id));
|
||||
return sprintf('<img class="p-3" src="%s">',url('p/thumbnail',$this->id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +142,7 @@ class Photo extends Abstracted\Catalog
|
||||
return $imo->getImageBlob();
|
||||
}
|
||||
|
||||
public function property($property)
|
||||
public function property(string $property)
|
||||
{
|
||||
if (! $this->o())
|
||||
return NULL;
|
||||
@@ -175,10 +174,6 @@ class Photo extends Abstracted\Catalog
|
||||
return $this->o() ? $this->_o->getImageProperties() : [];
|
||||
}
|
||||
|
||||
public function getDateCreatedAttribute() {
|
||||
return Carbon::createFromTimestamp($this->attributes['date_created']);
|
||||
}
|
||||
|
||||
public function setDateCreated()
|
||||
{
|
||||
$this->date_created = $this->property('creationdate');
|
||||
|
@@ -3,16 +3,22 @@
|
||||
namespace App\Models;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Video extends Abstracted\Catalog
|
||||
{
|
||||
// ID3 Object
|
||||
private $_o = NULL;
|
||||
|
||||
public function getIDLinkAttribute()
|
||||
{
|
||||
return $this->HTMLLinkAttribute($this->id,url('v/info').'/');
|
||||
}
|
||||
public function getIDLinkAttribute()
|
||||
{
|
||||
return $this->HTMLLinkAttribute($this->id,url('v/info').'/');
|
||||
}
|
||||
|
||||
public function getHtmlImageURL()
|
||||
{
|
||||
return sprintf('<video width="320" height="240" src="%s" controls></video>',url('/v/view/'.$this->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an GetID3 object or attribute
|
||||
@@ -33,44 +39,45 @@ class Video extends Abstracted\Catalog
|
||||
return is_null($attr) ? $this->_o : (array_key_exists($attr,$this->_o->info) ? $this->_o->info[$attr] : NULL);
|
||||
}
|
||||
|
||||
public function property($property)
|
||||
public function property(string $property)
|
||||
{
|
||||
if (! $this->o())
|
||||
return NULL;
|
||||
|
||||
switch ($property)
|
||||
{
|
||||
switch ($property) {
|
||||
case 'creationdate':
|
||||
// Try creation_Data
|
||||
$x = array_get($this->_o->info,'quicktime.comments.creation_date.0');
|
||||
$x = Arr::get($this->_o->info,'quicktime.comments.creation_date.0');
|
||||
|
||||
// Try creation_Data
|
||||
if (is_null($x))
|
||||
$x = array_get($this->_o->info,'quicktime.comments.creationdate.0');
|
||||
$x = Arr::get($this->_o->info,'quicktime.comments.creationdate.0');
|
||||
|
||||
return $x;
|
||||
|
||||
case 'make': return array_get($this->_o->info,'quicktime.comments.make.0');
|
||||
case 'model': return array_get($this->_o->info,'quicktime.comments.model.0');
|
||||
case 'software': return array_get($this->_o->info,'quicktime.comments.software.0');
|
||||
case 'signature': return array_get($this->_o->info,'sha1_data');
|
||||
case 'make': return Arr::get($this->_o->info,'quicktime.comments.make.0');
|
||||
case 'model': return Arr::get($this->_o->info,'quicktime.comments.model.0');
|
||||
case 'software': return Arr::get($this->_o->info,'quicktime.comments.software.0');
|
||||
case 'signature': return Arr::get($this->_o->info,'sha1_data');
|
||||
#case 'height': return $this->subatomsearch('quicktime.moov.subatoms',['trak','tkhd'],'height'); break;
|
||||
#case 'width': return $this->subatomsearch('quicktime.moov.subatoms',['trak','tkhd'],'width'); break;
|
||||
case 'height': return array_get($this->_o->info,'video.resolution_y');
|
||||
case 'width': return array_get($this->_o->info,'video.resolution_x');
|
||||
case 'length': return array_get($this->_o->info,'playtime_seconds');
|
||||
case 'type': return array_get($this->_o->info,'video.dataformat');
|
||||
case 'codec': return array_get($this->_o->info,'audio.codec');
|
||||
case 'audiochannels': return array_get($this->_o->info,'audio.channels');
|
||||
case 'samplerate': return array_get($this->_o->info,'audio.sample_rate');
|
||||
case 'channelmode': return array_get($this->_o->info,'audio.channelmode');
|
||||
case 'gps_lat': return array_get($this->_o->info,'quicktime.comments.gps_latitude.0');
|
||||
case 'gps_lon': return array_get($this->_o->info,'quicktime.comments.gps_longitude.0');
|
||||
case 'gps_altitude': return array_get($this->_o->info,'quicktime.comments.gps_altitude.0');
|
||||
case 'identifier': if ($x=array_get($this->_o->info,'quicktime.comments')) {
|
||||
return array_get(array_flatten(array_only($x,'content.identifier')),0);
|
||||
case 'height': return Arr::get($this->_o->info,'video.resolution_y');
|
||||
case 'width': return Arr::get($this->_o->info,'video.resolution_x');
|
||||
case 'length': return Arr::get($this->_o->info,'playtime_seconds');
|
||||
case 'type': return Arr::get($this->_o->info,'video.dataformat');
|
||||
case 'codec': return Arr::get($this->_o->info,'audio.codec');
|
||||
case 'audiochannels': return Arr::get($this->_o->info,'audio.channels');
|
||||
case 'samplerate': return Arr::get($this->_o->info,'audio.sample_rate');
|
||||
case 'channelmode': return Arr::get($this->_o->info,'audio.channelmode');
|
||||
case 'gps_lat': return Arr::get($this->_o->info,'quicktime.comments.gps_latitude.0');
|
||||
case 'gps_lon': return Arr::get($this->_o->info,'quicktime.comments.gps_longitude.0');
|
||||
case 'gps_altitude': return Arr::get($this->_o->info,'quicktime.comments.gps_altitude.0');
|
||||
case 'identifier':
|
||||
if ($x=Arr::get($this->_o->info,'quicktime.comments')) {
|
||||
return Arr::get(Arr::flatten(Arr::only($x,'content.identifier')),0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -85,24 +92,23 @@ class Video extends Abstracted\Catalog
|
||||
* Navigate through ID3 data to find the value.
|
||||
*/
|
||||
private function subatomsearch($atom,array $paths,$key,array $data=[]) {
|
||||
if (! $data AND is_null($data = array_get($this->_o->info,$atom)))
|
||||
{
|
||||
if (! $data AND is_null($data = Arr::get($this->_o->info,$atom))) {
|
||||
// Didnt find it.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
foreach ($paths as $path) {
|
||||
$found = FALSE;
|
||||
foreach ($data as $array)
|
||||
{
|
||||
if ($array['name'] === $path)
|
||||
{
|
||||
|
||||
foreach ($data as $array) {
|
||||
if ($array['name'] === $path) {
|
||||
$found = TRUE;
|
||||
|
||||
if ($path != last($paths))
|
||||
$data = $array['subatoms'];
|
||||
else
|
||||
$data = $array;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -170,9 +176,4 @@ class Video extends Abstracted\Catalog
|
||||
{
|
||||
return strtolower($mime ? File::mime_by_ext(pathinfo($this->filename,PATHINFO_EXTENSION)) : pathinfo($this->filename,PATHINFO_EXTENSION));
|
||||
}
|
||||
|
||||
public function getHtmlImageURL()
|
||||
{
|
||||
return sprintf('<video width="320" height="240" src="%s" controls></video>',url('/v/view/'.$this->id));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user