Compare commits
	
		
			4 Commits
		
	
	
		
			65a1ea5a07
			...
			181dc108c1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 181dc108c1 | ||
|  | 58c8091447 | ||
|  | b5a4e42c7e | ||
|  | ad921d10a1 | 
|  | @ -0,0 +1,59 @@ | ||||||
|  | APP_NAME=Laravel | ||||||
|  | APP_ENV=local | ||||||
|  | APP_KEY= | ||||||
|  | APP_DEBUG=true | ||||||
|  | APP_URL=http://localhost | ||||||
|  | 
 | ||||||
|  | LOG_CHANNEL=stack | ||||||
|  | LOG_DEPRECATIONS_CHANNEL=null | ||||||
|  | LOG_LEVEL=debug | ||||||
|  | 
 | ||||||
|  | DB_CONNECTION=mysql | ||||||
|  | DB_HOST=127.0.0.1 | ||||||
|  | DB_PORT=3306 | ||||||
|  | DB_DATABASE=laravel | ||||||
|  | DB_USERNAME=root | ||||||
|  | DB_PASSWORD= | ||||||
|  | 
 | ||||||
|  | BROADCAST_DRIVER=log | ||||||
|  | CACHE_DRIVER=file | ||||||
|  | FILESYSTEM_DISK=local | ||||||
|  | QUEUE_CONNECTION=sync | ||||||
|  | SESSION_DRIVER=file | ||||||
|  | SESSION_LIFETIME=120 | ||||||
|  | 
 | ||||||
|  | MEMCACHED_HOST=127.0.0.1 | ||||||
|  | 
 | ||||||
|  | REDIS_HOST=127.0.0.1 | ||||||
|  | REDIS_PASSWORD=null | ||||||
|  | REDIS_PORT=6379 | ||||||
|  | 
 | ||||||
|  | MAIL_MAILER=smtp | ||||||
|  | MAIL_HOST=mailpit | ||||||
|  | MAIL_PORT=1025 | ||||||
|  | MAIL_USERNAME=null | ||||||
|  | MAIL_PASSWORD=null | ||||||
|  | MAIL_ENCRYPTION=null | ||||||
|  | MAIL_FROM_ADDRESS="hello@example.com" | ||||||
|  | MAIL_FROM_NAME="${APP_NAME}" | ||||||
|  | 
 | ||||||
|  | AWS_ACCESS_KEY_ID= | ||||||
|  | AWS_SECRET_ACCESS_KEY= | ||||||
|  | AWS_DEFAULT_REGION=us-east-1 | ||||||
|  | AWS_BUCKET= | ||||||
|  | AWS_USE_PATH_STYLE_ENDPOINT=false | ||||||
|  | 
 | ||||||
|  | PUSHER_APP_ID= | ||||||
|  | PUSHER_APP_KEY= | ||||||
|  | PUSHER_APP_SECRET= | ||||||
|  | PUSHER_HOST= | ||||||
|  | PUSHER_PORT=443 | ||||||
|  | PUSHER_SCHEME=https | ||||||
|  | PUSHER_APP_CLUSTER=mt1 | ||||||
|  | 
 | ||||||
|  | VITE_APP_NAME="${APP_NAME}" | ||||||
|  | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | ||||||
|  | VITE_PUSHER_HOST="${PUSHER_HOST}" | ||||||
|  | VITE_PUSHER_PORT="${PUSHER_PORT}" | ||||||
|  | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" | ||||||
|  | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" | ||||||
|  | @ -0,0 +1,42 @@ | ||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | namespace App\Console\Commands; | ||||||
|  | 
 | ||||||
|  | use Illuminate\Console\Command; | ||||||
|  | use Illuminate\Filesystem\Filesystem; | ||||||
|  | 
 | ||||||
|  | class ClearDownloads extends Command | ||||||
|  | { | ||||||
|  |     /** | ||||||
|  |      * The name and signature of the console command. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected $signature = 'app:clear-downloads'; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The console command description. | ||||||
|  |      * | ||||||
|  |      * @var string | ||||||
|  |      */ | ||||||
|  |     protected $description = 'Command description'; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Execute the console command. | ||||||
|  |      */ | ||||||
|  |     public function handle() | ||||||
|  |     { | ||||||
|  |         $this->info("Clearing download directory: " . env('PATH_TO_DOWNLOAD')); | ||||||
|  |         $directory = new Filesystem(); | ||||||
|  |         $files = $directory->files(env('PATH_TO_DOWNLOAD'), false); | ||||||
|  |         $counter = 0; | ||||||
|  |         foreach ($files as $file){ | ||||||
|  |             if ($file->getFilename() !== '.gitignore'){ | ||||||
|  |                 $this->info("rm " . $file->getRealPath()); | ||||||
|  |                 unlink($file->getRealPath()); | ||||||
|  |                 $counter++; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         $this->info("Deleted " . $counter . " file(s)"); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -13,6 +13,7 @@ class Kernel extends ConsoleKernel | ||||||
|     protected function schedule(Schedule $schedule): void |     protected function schedule(Schedule $schedule): void | ||||||
|     { |     { | ||||||
|         // $schedule->command('inspire')->hourly();
 |         // $schedule->command('inspire')->hourly();
 | ||||||
|  |         $schedule->command('app:clear-downloads')->daily(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  |  | ||||||
|  | @ -11,6 +11,6 @@ public function download($file_name) { | ||||||
|         $headers = [ |         $headers = [ | ||||||
|             'Content-Type' => 'video/mp4', |             'Content-Type' => 'video/mp4', | ||||||
|         ]; |         ]; | ||||||
|         return response()->download($file_path, $file_name, $headers); |         return response()->download($file_path, $file_name, $headers)->deleteFileAfterSend(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -30,8 +30,11 @@ public function index(Request $request) | ||||||
|                 return response(json_encode($response)); |                 return response(json_encode($response)); | ||||||
|             } else { |             } else { | ||||||
|                 $videotitle = $video->getFile()->getFilename(); |                 $videotitle = $video->getFile()->getFilename(); | ||||||
|  |                 $thumbnails = $video->getThumbnails(); | ||||||
|  |                 $thumbnail = $thumbnails[0]?->getUrl(); | ||||||
|                 $response = new \stdClass(); |                 $response = new \stdClass(); | ||||||
|                 $response->link = $videotitle; |                 $response->link = $videotitle; | ||||||
|  |                 $response->thumbnail = $thumbnail; | ||||||
|                 return response(json_encode($response)); |                 return response(json_encode($response)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -46,7 +46,7 @@ export default { | ||||||
|             this.downloadAvailable = false; |             this.downloadAvailable = false; | ||||||
|             this.error = false; |             this.error = false; | ||||||
|             this.fetching = true; |             this.fetching = true; | ||||||
|             axios.get(`/download_api?videourl=${this.url}`).then((responce)=>{ |             axios.get(`/api/v1/video/download?videourl=${this.url}`).then((responce)=>{ | ||||||
|                 this.fetching = false; |                 this.fetching = false; | ||||||
|                 if (responce.data.error){ |                 if (responce.data.error){ | ||||||
|                     this.error = true; |                     this.error = true; | ||||||
|  | @ -55,7 +55,7 @@ export default { | ||||||
|                     console.log(responce.data.error); |                     console.log(responce.data.error); | ||||||
|                 } else if (responce.data.link){ |                 } else if (responce.data.link){ | ||||||
|                     this.downloadAvailable = true; |                     this.downloadAvailable = true; | ||||||
|                     this.downloadLink = `/download/${responce.data.link}`; |                     this.downloadLink = `/api/v1/file/download/${responce.data.link}`; | ||||||
|                 } |                 } | ||||||
|             }).catch((error)=>{ |             }).catch((error)=>{ | ||||||
|                 this.fetching = false; |                 this.fetching = false; | ||||||
|  |  | ||||||
|  | @ -17,3 +17,12 @@ | ||||||
| Route::middleware('auth:sanctum')->get('/user', function (Request $request) { | Route::middleware('auth:sanctum')->get('/user', function (Request $request) { | ||||||
|     return $request->user(); |     return $request->user(); | ||||||
| }); | }); | ||||||
|  | 
 | ||||||
|  | Route::group(['prefix' => 'v1'], function () { | ||||||
|  |     Route::group(['prefix' => 'video'], function () { | ||||||
|  |         Route::get('/download', 'App\Http\Controllers\YoutubeDownloadController@index'); | ||||||
|  |     }); | ||||||
|  |     Route::group(['prefix' => 'file'], function () { | ||||||
|  |         Route::get('/download/{file}', 'App\Http\Controllers\DownloadController@download')->name('download'); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | @ -16,6 +16,3 @@ | ||||||
| Route::get('/', function () { | Route::get('/', function () { | ||||||
|     return view('welcome'); |     return view('welcome'); | ||||||
| }); | }); | ||||||
| 
 |  | ||||||
| Route::get('/download_api', 'App\Http\Controllers\YoutubeDownloadController@index'); |  | ||||||
| Route::get('/download/{file}', 'App\Http\Controllers\DownloadController@download')->name('download'); |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue