- Can I use this package in a Laravel application without shelling out to youtube-dl?
- Yes, this package is a pure PHP implementation with no shell dependencies. It fetches direct stream links entirely within your Laravel app, avoiding external binaries like youtube-dl or yt-dlp.
- What Laravel versions does this package support?
- The package requires PHP 7.4+ and works seamlessly with Laravel 8.0+ (LTS). It aligns with Laravel’s dependency management via Composer and supports modern features like type declarations for better IDE integration.
- How do I handle rate limiting or throttling from YouTube?
- YouTube may throttle requests (e.g., 100 kb/s limit). Mitigate this by using Laravel’s retry helper or queue delays (e.g., `delay(60)`) for staggered downloads. Proxy rotation via `Browser::setProxy()` can also help.
- Is this package suitable for production use with high download volumes?
- For high-volume use, test performance under load as pure PHP may struggle with concurrent downloads. Consider offloading tasks to Laravel Queues and monitor GitHub issues for breaking changes due to YouTube’s frequent API updates.
- How do I merge audio and video streams if they’re separate?
- This package returns separate audio and combined audio+video streams. To merge them, you’ll need FFmpeg installed on your server. Use FFmpeg CLI commands or a Laravel wrapper like `spatie/laravel-ffmpeg` for automation.
- Does this package support live streaming or age-restricted YouTube content?
- Live streaming is supported via the `YouTubeStreamer` class, enabling direct playback from your Laravel server. For age-restricted content, manually handle cookies (e.g., export from browsers) or use Laravel’s session management.
- What are the legal risks of using this package in a Laravel app?
- YouTube’s Terms of Service prohibit scraping, so integration may pose legal risks. Use this package only for internal tools (e.g., moderation, analytics) and consult legal teams before deploying to production, especially for commercial applications.
- How do I integrate this with Laravel’s queue system for background downloads?
- Wrap the `getDownloadLinks()` method in a Laravel job (e.g., `php artisan make:job DownloadYouTubeVideo`) and dispatch it to the queue. Use `delay()` for staggered processing and handle failures with Laravel’s retry logic.
- Are there alternatives to this package for Laravel?
- Alternatives include PHP wrappers for `yt-dlp` (e.g., `php-yt-dlp`) or direct API calls via YouTube’s official API (paid). However, this package is unique for being a pure PHP, actively maintained solution without shell dependencies.
- How do I store downloaded video metadata in Laravel’s database?
- The `VideoInfo` object returned by the package can be serialized and stored in a Laravel database (e.g., JSON column). Use Eloquent models or DTOs to structure metadata for analytics, caching, or auditing.