From 04dbef81f6bd743b0daa3105e5ea7c290396e8ad Mon Sep 17 00:00:00 2001 From: Dhaverd Date: Tue, 18 Jun 2024 06:21:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=20=D0=B5=D1=89=D0=B5=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/YoutubeDownloadController.php | 5 ++++- resources/views/Main.vue | 6 ++++-- routes/web.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/YoutubeDownloadController.php b/app/Http/Controllers/YoutubeDownloadController.php index 3b64ff9..2b0efe2 100644 --- a/app/Http/Controllers/YoutubeDownloadController.php +++ b/app/Http/Controllers/YoutubeDownloadController.php @@ -28,9 +28,12 @@ class YoutubeDownloadController extends Controller return response(json_encode($response)); } else { $videotitle = $video->getFile()->getFilename(); // Will return Phonebloks + $videotitle = str_replace('webp', 'mp4', $videotitle); + //$file_path = public_path('/'.'downloads/'.$videotitle); + //return response()->download($file_path); // $video->getFile(); // \SplFileInfo instance of downloaded file //$file_path = public_path('/downloads/'.$videotitle); - return redirect()->route('/download/'.$videotitle); + return redirect()->route('download', [$videotitle]); //return response()->download($file_path); } } diff --git a/resources/views/Main.vue b/resources/views/Main.vue index 88ca996..d8543e8 100644 --- a/resources/views/Main.vue +++ b/resources/views/Main.vue @@ -20,12 +20,14 @@ export default { name: "Main", data: () => ({ url: ref(''), + fetching: ref(false) }), methods: { startDownload(){ - console.log(this.url); + this.fetching = true; axios.get(`/download_api?videourl=${this.url}`).then((responce)=>{ - console.log(responce); + this.fetching = false; + console.log(responce); }) } } diff --git a/routes/web.php b/routes/web.php index ed83ab3..5d1f956 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,4 +18,4 @@ Route::get('/', function () { }); Route::get('/download_api', 'App\Http\Controllers\YoutubeDownloadController@index'); -Route::get('/download/{file}', 'App\Http\Controllers\DownloadController@download'); +Route::get('/download/{file}', 'App\Http\Controllers\DownloadController@download')->name('download');