Исправляем
This commit is contained in:
parent
750fcf6f31
commit
32abf4ad92
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class DownloadController extends Controller
|
||||||
|
{
|
||||||
|
public function download($file_name) {
|
||||||
|
$file_path = public_path('/'.$file_name);
|
||||||
|
return response()->download($file_path);
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,8 +15,9 @@ class YoutubeDownloadController extends Controller
|
||||||
|
|
||||||
$collection = $yt->download(
|
$collection = $yt->download(
|
||||||
Options::create()
|
Options::create()
|
||||||
->downloadPath('/path/to/downloads')
|
->downloadPath(env('PATH_TO_DOWNLOAD'))
|
||||||
->url($url)
|
->url($url)
|
||||||
|
->remuxVideo('mp4')
|
||||||
);
|
);
|
||||||
$videotitle = '';
|
$videotitle = '';
|
||||||
foreach ($collection->getVideos() as $video) {
|
foreach ($collection->getVideos() as $video) {
|
||||||
|
@ -26,10 +27,11 @@ class YoutubeDownloadController extends Controller
|
||||||
$response->error = $error;
|
$response->error = $error;
|
||||||
return response(json_encode($response));
|
return response(json_encode($response));
|
||||||
} else {
|
} else {
|
||||||
$videotitle = $video->getTitle(); // Will return Phonebloks
|
$videotitle = $video->getFile()->getFilename(); // Will return Phonebloks
|
||||||
// $video->getFile(); // \SplFileInfo instance of downloaded file
|
// $video->getFile(); // \SplFileInfo instance of downloaded file
|
||||||
$file_path = public_path('/downloads/'.$videotitle);
|
//$file_path = public_path('/downloads/'.$videotitle);
|
||||||
return response()->download($file_path);
|
return redirect('/download/'.$videotitle);
|
||||||
|
//return response()->download($file_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$response = new \stdClass();
|
$response = new \stdClass();
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
startDownload(){
|
startDownload(){
|
||||||
console.log(this.url);
|
console.log(this.url);
|
||||||
axios.get(`/download?videourl=${this.url}`).then((responce)=>{
|
axios.get(`/download_api?videourl=${this.url}`).then((responce)=>{
|
||||||
console.log(responce);
|
console.log(responce);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,5 @@ Route::get('/', function () {
|
||||||
return view('welcome');
|
return view('welcome');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/download', 'App\Http\Controllers\YoutubeDownloadController@index');
|
Route::get('/download_api', 'App\Http\Controllers\YoutubeDownloadController@index');
|
||||||
|
Route::get('/download/{file}', 'App\Http\Controllers\DownloadController@index');
|
||||||
|
|
Loading…
Reference in New Issue