From a86a7d2769d73869bdb60cd79554859e651b7d64 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 25 May 2019 18:56:21 -0600 Subject: [PATCH 01/52] Hello Loops --- app/Http/Controllers/DiscoverController.php | 5 +++++ resources/views/discover/loops/home.blade.php | 5 +++++ routes/web.php | 1 + 3 files changed, 11 insertions(+) create mode 100644 resources/views/discover/loops/home.blade.php diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index 0c87954e0..dbe08becf 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -115,4 +115,9 @@ class DiscoverController extends Controller }); return view('discover.personal', compact('posts', 'tags')); } + + public function showLoops(Request $request) + { + return view('discover.loops.home'); + } } diff --git a/resources/views/discover/loops/home.blade.php b/resources/views/discover/loops/home.blade.php new file mode 100644 index 000000000..d231d559c --- /dev/null +++ b/resources/views/discover/loops/home.blade.php @@ -0,0 +1,5 @@ +@extends('layouts.app') + +@section('content') + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 80dc86e50..10ea2fc1a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -62,6 +62,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('discover/c/{slug}', 'DiscoverController@showCategory'); Route::get('discover/personal', 'DiscoverController@showPersonal'); Route::get('discover', 'DiscoverController@home')->name('discover'); + Route::get('discover/loops', 'DiscoverController@showLoops'); Route::group(['prefix' => 'api'], function () { Route::get('search', 'SearchController@searchAPI'); From 7f437d47146304b7dded92e9a7942a89e24d7e91 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 May 2019 18:34:54 -0600 Subject: [PATCH 02/52] Add VideoThumbnail command --- app/Console/Commands/VideoThumbnail.php | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 app/Console/Commands/VideoThumbnail.php diff --git a/app/Console/Commands/VideoThumbnail.php b/app/Console/Commands/VideoThumbnail.php new file mode 100644 index 000000000..c2d01aa63 --- /dev/null +++ b/app/Console/Commands/VideoThumbnail.php @@ -0,0 +1,52 @@ +whereNull('thumbnail_path') + ->take($limit) + ->get(); + foreach($videos as $video) { + Pipeline::dispatchNow($video); + } + } +} From a1c29b50e3589e362a73d359dc3560db98cc2fe5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 May 2019 18:36:04 -0600 Subject: [PATCH 03/52] Update VideoPipeline --- app/Jobs/VideoPipeline/VideoThumbnail.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Jobs/VideoPipeline/VideoThumbnail.php b/app/Jobs/VideoPipeline/VideoThumbnail.php index c6000d222..882f57dd6 100644 --- a/app/Jobs/VideoPipeline/VideoThumbnail.php +++ b/app/Jobs/VideoPipeline/VideoThumbnail.php @@ -34,6 +34,9 @@ class VideoThumbnail implements ShouldQueue public function handle() { $media = $this->media; + if($media->mime != 'video/mp4') { + return; + } $base = $media->media_path; $path = explode('/', $base); $name = last($path); @@ -43,14 +46,11 @@ class VideoThumbnail implements ShouldQueue $i = count($path) - 1; $path[$i] = $t; $save = implode('/', $path); - $video = FFMpeg::open($base); - if($video->getDurationInSeconds() < 1) { - $video->getFrameFromSeconds(0); - } elseif($video->getDurationInSeconds() < 5) { - $video->getFrameFromSeconds(4); - } - $video->export() - ->save($save); + $video = FFMpeg::open($base) + ->getFrameFromSeconds(1) + ->export() + ->toDisk('local') + ->save($save); $media->thumbnail_path = $save; $media->save(); From 76f651429358c1303e68e5246078045cffd742a7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 May 2019 18:40:09 -0600 Subject: [PATCH 04/52] Update BaseApiController --- .../Controllers/Api/BaseApiController.php | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index 3110aad7d..edcc36557 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -48,7 +48,8 @@ class BaseApiController extends Controller public function notifications(Request $request) { $pid = Auth::user()->profile->id; - if(config('exp.ns') == false) { + $pg = $request->input('pg'); + if($pg == true) { $timeago = Carbon::now()->subMonths(6); $notifications = Notification::whereProfileId($pid) ->whereDate('created_at', '>', $timeago) @@ -272,6 +273,7 @@ class BaseApiController extends Controller 'temp-media', now()->addHours(1), ['profileId' => $profile->id, 'mediaId' => $media->id] ); + $preview_url = $url; switch ($media->mime) { case 'image/jpeg': case 'image/png': @@ -280,6 +282,8 @@ class BaseApiController extends Controller case 'video/mp4': VideoThumbnail::dispatch($media); + $preview_url = '/storage/no-preview.png'; + $url = '/storage/no-preview.png'; break; default: @@ -288,7 +292,7 @@ class BaseApiController extends Controller $resource = new Fractal\Resource\Item($media, new MediaTransformer()); $res = $this->fractal->createData($resource)->toArray(); - $res['preview_url'] = $url; + $res['preview_url'] = $preview_url; $res['url'] = $url; return response()->json($res); } @@ -327,4 +331,34 @@ class BaseApiController extends Controller return response()->json($res); } + public function loops(Request $request) + { + abort_if(!Auth::check(), 403); + abort_if(!config('exp.loops'), 403); + + // todo proper pagination, maybe LoopService + $loops = Status::whereType('video') + ->latest() + ->take(18) + ->get(); + + $resource = new Fractal\Resource\Collection($loops, new StatusTransformer()); + return $this->fractal->createData($resource)->toArray(); + } + + + public function loopWatch(Request $request) + { + abort_if(!Auth::check(), 403); + abort_if(!config('exp.loops'), 403); + + $this->validate($request, [ + 'id' => 'integer|min:1' + ]); + $id = $request->input('id'); + + // todo log loops + + return response()->json(200); + } } From 9dbeea41ee4ee582b2ff90df2c80d1235593df38 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 May 2019 18:40:30 -0600 Subject: [PATCH 05/52] Update config --- config/exp.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/exp.php b/config/exp.php index 3c8d7f8a5..1c4bf45c6 100644 --- a/config/exp.php +++ b/config/exp.php @@ -4,6 +4,7 @@ return [ 'lc' => env('EXP_LC', false), 'rec' => env('EXP_REC', false), - 'ns' => env('EXP_NS', false) + 'ns' => env('EXP_NS', false), + 'loops' => env('EXP_LOOPS', false) ]; \ No newline at end of file From 1bfb1ae8822e2847108d78c7fb06e49b7af5a701 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 May 2019 18:42:12 -0600 Subject: [PATCH 06/52] Update loops blade view --- resources/views/discover/loops/home.blade.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/resources/views/discover/loops/home.blade.php b/resources/views/discover/loops/home.blade.php index d231d559c..b1213b70b 100644 --- a/resources/views/discover/loops/home.blade.php +++ b/resources/views/discover/loops/home.blade.php @@ -1,5 +1,39 @@ @extends('layouts.app') @section('content') +
+
+
+
+
+

Loops BETA

+

Short looping videos

+
+
+
+
+
+
+ +
+
+@endsection -@endsection \ No newline at end of file +@push('styles') + +@endpush +@push('scripts') + + + +@endpush \ No newline at end of file From c84e440bbb98ae95161527ae5085b66108dd1446 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 May 2019 18:42:42 -0600 Subject: [PATCH 07/52] Update app layout --- resources/views/layouts/app.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index ef9b714a0..30a686491 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -56,19 +56,19 @@
From e7d61d4ebceee85a36bab618fbbb6158316a49f3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 May 2019 18:43:18 -0600 Subject: [PATCH 08/52] Update nav view --- resources/views/layouts/partial/nav.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/layouts/partial/nav.blade.php b/resources/views/layouts/partial/nav.blade.php index 53144889c..360d267da 100644 --- a/resources/views/layouts/partial/nav.blade.php +++ b/resources/views/layouts/partial/nav.blade.php @@ -27,18 +27,18 @@