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');