diff --git a/app/Console/Commands/SyncVideosCommand.php b/app/Console/Commands/SyncVideosCommand.php index f5a7cfa67..96303b395 100644 --- a/app/Console/Commands/SyncVideosCommand.php +++ b/app/Console/Commands/SyncVideosCommand.php @@ -51,15 +51,15 @@ class SyncVideosCommand extends Command $flag = false; try { $metaData = $fs->getMetadata($video->path); - $flag = !$metaData || $metaData['filename'] !== $video->alias || $metaData['path'] !== $video->path; + $flag = !$metaData || $metaData['basename'] !== $video->basename || $metaData['filename'] !== $video->filename || $metaData['path'] !== $video->path; } catch (FileNotFoundException $fnf) { $flag = true; } catch (RequestException $r) { - Log::error('verify video', ['alias' => $video->alias, 'path' => $video->path]); + Log::error('verify video', ['basename' => $video->basename, 'filename' => $video->filename, 'path' => $video->path]); } if ($flag) { - LOG::info('delete video', ['alias' => $video->alias, 'path' => $video->path]); + LOG::info('delete video', ['basename' => $video->basename, 'filename' => $video->filename, 'path' => $video->path]); $video->delete(); } } @@ -69,11 +69,12 @@ class SyncVideosCommand extends Command foreach ($files as $file) { $isFile = $file['type'] == 'file'; if ($isFile) { - $video = Video::where('alias', $file['filename'])->where('path', $file['path'])->first(); + $video = Video::where('basename', $file['basename'])->where('filename', $file['filename'])->where('path', $file['path'])->first(); if (!$video) { - LOG::info('create video', ['alias' => $file['filename'], 'path' => $file['path']]); + LOG::info('create video', ['basename' => $file['basename'], 'filename' => $file['filename'], 'path' => $file['path']]); Video::create(array( - 'alias' => $file['filename'], + 'basename' => $file['basename'], + 'filename' => $file['filename'], 'path' => $file['path'] )); } diff --git a/app/Http/Controllers/VideosController.php b/app/Http/Controllers/VideosController.php index fcc4860bc..dbc5017fd 100644 --- a/app/Http/Controllers/VideosController.php +++ b/app/Http/Controllers/VideosController.php @@ -10,7 +10,7 @@ class VideosController extends Controller { public function index() { - $videos = Video::orderByRaw('udf_NaturalSortFormat(alias, 10, ".")')->paginate(50); + $videos = Video::orderByRaw('udf_NaturalSortFormat(filename, 10, ".")')->paginate(50); return view('videos', [ 'videos' => $videos @@ -20,7 +20,7 @@ class VideosController extends Controller public function show($alias) { set_time_limit(0); - $video = Video::where('alias', $alias)->firstOrFail(); + $video = Video::where('basename', $alias)->orWhere('filename', $alias)->firstOrFail(); return Storage::disk('spaces')->response($video->path, null, ['Accept-Ranges' => 'bytes']); } diff --git a/app/Models/Video.php b/app/Models/Video.php index d33a9fc1a..cbec51f9a 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -6,5 +6,5 @@ use Illuminate\Database\Eloquent\Model; class Video extends Model { - protected $fillable = ['alias', 'path']; + protected $fillable = ['basename', 'filename', 'path']; } diff --git a/composer.json b/composer.json index 5e0dc22e7..7574e027c 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "type": "project", "require": { "php": ">=7.0.0", + "doctrine/dbal": "^2.6", "fideloper/proxy": "~3.3", "laravel/framework": "5.5.*", "laravel/tinker": "~1.0", diff --git a/composer.lock b/composer.lock index 825b7e292..04c662a92 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "1fd7d6a7e7df84d1f40d186988b63570", + "content-hash": "931c23714761f60d1659f0bb5a44153f", "packages": [ { "name": "aws/aws-sdk-php", - "version": "3.52.23", + "version": "3.52.34", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "3ce95b96c217a699168d937c4ed700e6a27ec783" + "reference": "c414752f2f88a036958438a3d973475c6786a387" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3ce95b96c217a699168d937c4ed700e6a27ec783", - "reference": "3ce95b96c217a699168d937c4ed700e6a27ec783", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c414752f2f88a036958438a3d973475c6786a387", + "reference": "c414752f2f88a036958438a3d973475c6786a387", "shasum": "" }, "require": { @@ -84,7 +84,7 @@ "s3", "sdk" ], - "time": "2018-03-08T22:51:35+00:00" + "time": "2018-03-27T19:13:06+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -119,6 +119,361 @@ "description": "implementation of xdg base directory specification for php", "time": "2014-10-24T07:27:01+00:00" }, + { + "name": "doctrine/annotations", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-12-06T07:11:42+00:00" + }, + { + "name": "doctrine/cache", + "version": "v1.7.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^5.7", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2017-08-25T07:02:50+00:00" + }, + { + "name": "doctrine/collections", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "~0.1@dev", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2017-07-22T10:37:32+00:00" + }, + { + "name": "doctrine/common", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~7.1" + }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2017-08-31T08:43:38+00:00" + }, + { + "name": "doctrine/dbal", + "version": "v2.6.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/e3eed9b1facbb0ced3a0995244843a189e7d1b13", + "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13", + "shasum": "" + }, + "require": { + "doctrine/common": "^2.7.1", + "ext-pdo": "*", + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^5.4.6", + "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", + "symfony/console": "2.*||^3.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ], + "time": "2017-11-19T13:38:54+00:00" + }, { "name": "doctrine/inflector", "version": "v1.3.0", @@ -402,16 +757,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.3.0", + "version": "6.3.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699" + "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/68d0ea14d5a3f42a20e87632a5f84931e2709c90", + "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90", "shasum": "" }, "require": { @@ -421,7 +776,7 @@ }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^4.0 || ^5.0", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4", "psr/log": "^1.0" }, "suggest": { @@ -430,7 +785,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "6.3-dev" } }, "autoload": { @@ -463,7 +818,7 @@ "rest", "web service" ], - "time": "2017-06-22T18:50:49+00:00" + "time": "2018-03-26T16:33:04+00:00" }, { "name": "guzzlehttp/promises", @@ -951,16 +1306,16 @@ }, { "name": "league/flysystem-aws-s3-v3", - "version": "1.0.18", + "version": "1.0.19", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git", - "reference": "dc09b19f455750663b922ed52dcc0ff215bed284" + "reference": "f135691ef6761542af301b7c9880f140fb12dc74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/dc09b19f455750663b922ed52dcc0ff215bed284", - "reference": "dc09b19f455750663b922ed52dcc0ff215bed284", + "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/f135691ef6761542af301b7c9880f140fb12dc74", + "reference": "f135691ef6761542af301b7c9880f140fb12dc74", "shasum": "" }, "require": { @@ -994,7 +1349,7 @@ } ], "description": "Flysystem adapter for the AWS S3 SDK v3.x", - "time": "2017-06-30T06:29:25+00:00" + "time": "2018-03-27T20:33:59+00:00" }, { "name": "monolog/monolog", @@ -1175,16 +1530,16 @@ }, { "name": "nesbot/carbon", - "version": "1.24.1", + "version": "1.25.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "ef12cbd8ba5ce624f0a6a95e0850c4cc13e71e41" + "reference": "cbcf13da0b531767e39eb86e9687f5deba9857b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ef12cbd8ba5ce624f0a6a95e0850c4cc13e71e41", - "reference": "ef12cbd8ba5ce624f0a6a95e0850c4cc13e71e41", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/cbcf13da0b531767e39eb86e9687f5deba9857b4", + "reference": "cbcf13da0b531767e39eb86e9687f5deba9857b4", "shasum": "" }, "require": { @@ -1224,7 +1579,7 @@ "datetime", "time" ], - "time": "2018-03-09T15:49:34+00:00" + "time": "2018-03-19T15:50:49+00:00" }, { "name": "nikic/php-parser", diff --git a/database/migrations/2018_03_28_023041_add_basename_to_videos_table.php b/database/migrations/2018_03_28_023041_add_basename_to_videos_table.php new file mode 100644 index 000000000..b33e24a5e --- /dev/null +++ b/database/migrations/2018_03_28_023041_add_basename_to_videos_table.php @@ -0,0 +1,34 @@ +string('basename'); + $table->renameColumn('alias', 'filename'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('videos', function (Blueprint $table) { + $table->dropColumn('basename'); + $table->renameColumn('filename', 'alias'); + }); + } +} diff --git a/database/seeds/VideosTableSeeder.php b/database/seeds/VideosTableSeeder.php index 0921b5c89..acd5b4ee0 100644 --- a/database/seeds/VideosTableSeeder.php +++ b/database/seeds/VideosTableSeeder.php @@ -17,7 +17,8 @@ class VideosTableSeeder extends Seeder $isFile = $file['type'] == 'file'; if ($isFile) { Video::create(array( - 'alias' => $file['filename'], + 'basename' => $file['basename'], + 'filename' => $file['filename'], 'path' => $file['path'] )); } diff --git a/resources/views/sitemap/videos.blade.php b/resources/views/sitemap/videos.blade.php index d1ed1af7f..bfc82fc5a 100644 --- a/resources/views/sitemap/videos.blade.php +++ b/resources/views/sitemap/videos.blade.php @@ -2,7 +2,7 @@ @foreach ($videos as $video) - {{ route('video.show', ['alias' => $video->alias]) }} + {{ route('video.show', ['alias' => $video->basename]) }} {{ $video->updated_at->tz('UTC')->toAtomString() }} weekly 0.6 diff --git a/resources/views/videos.blade.php b/resources/views/videos.blade.php index 5aa171042..b22e0c298 100644 --- a/resources/views/videos.blade.php +++ b/resources/views/videos.blade.php @@ -12,7 +12,7 @@
@foreach ($videos as $video) -

{{ $video->alias }}

+

{{ $video->filename }}

@endforeach