Download the PHP package aronpc/youtube-comments without Composer
On this page you can find all versions of the php package aronpc/youtube-comments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aronpc/youtube-comments
More information about aronpc/youtube-comments
Files in aronpc/youtube-comments
Package youtube-comments
Short Description A Laravel package to download YouTube comments without using API keys
License MIT
Informations about the package youtube-comments
YouTube Comments for Laravel
A Laravel package to download YouTube comments without using API keys, utilizing yt-dlp as the backend for extraction.
Requirements
- PHP 8.3 or higher
- Laravel 10.x or higher
- yt-dlp installed and accessible via terminal
Installation
-
Install the package via Composer:
-
The package will be automatically discovered by Laravel.
-
Publish the configuration file:
-
Install yt-dlp (if not already installed):
- Configure the package in
config/youtube-comments.phpif needed.
Usage
Using Artisan Commands
This package provides several Artisan commands to interact with YouTube comments and live chat.
Fetch Comments (All-in-one)
To fetch comments from a YouTube video in a single step (download and parse), use the following command:
Replace VIDEO_ID with the ID of the YouTube video. For example:
This will generate a file in the configured output directory named comments_VIDEO_ID.txt containing all the comments from the video.
Fetch Live Chat
To fetch live chat from a YouTube video that had a live stream, use:
This will generate a file in the configured output directory named livechat_VIDEO_ID.txt containing all the live chat messages from the video.
Fetch Both Comments and Live Chat
To fetch both comments and live chat in a single operation, use:
This will generate two files in the configured output directory:
comments_VIDEO_ID.txtcontaining all the commentslivechat_VIDEO_ID.txtcontaining all the live chat messages
If either comments or live chat are not available for the video, the command will still succeed but will display a warning message.
Download Comments Only
If you want to only download the comments and save them as a JSON file (useful for debugging), use:
This will generate a file in the configured output directory named comments_VIDEO_ID.json containing the raw JSON data.
Parse Comments Only
To parse previously downloaded comments from a JSON file, use:
This command expects a file named comments_VIDEO_ID.json to exist in the configured output directory.
Using the Facade
You can also use the provided facade to interact with the YouTube client directly in your code:
Output Format
The parsed comments are saved in a text file with the following format:
How It Works
- The application uses yt-dlp to download the comments from the YouTube video
- It processes the JSON data and formats the comments
- The formatted comments are saved to a text file in the output directory
Configuration
The package configuration file is located at config/youtube-comments.php after publishing. It includes the following options:
You can customize these settings by editing the configuration file or by setting the corresponding environment variables in your .env file.
Testing
The package includes a comprehensive test suite built with PHPUnit. The tests cover the main functionality of the package, including:
- Service classes (YouTubeClient)
- Command classes (FetchCommentsCommand, DownloadCommentsCommand, ParseCommentsCommand)
Running Tests
If you want to run the tests for this package, you can clone the repository and run:
Troubleshooting
- Make sure yt-dlp is installed and accessible from the command line
- Some videos may have comments disabled, in which case no comments will be downloaded
- Future live events that haven't started yet don't have comments available
- If you encounter any issues, try updating yt-dlp to the latest version
-
For video IDs that start with a hyphen (e.g., -6oKXN8D6BI), you need to use the
--separator to prevent the shell from interpreting the ID as a command option:Note: The package has special handling for video IDs that start with a hyphen to ensure they are processed correctly.
License
This package is open-sourced software licensed under the MIT license.
All versions of youtube-comments with dependencies
illuminate/support Version ^12.0
symfony/process Version ^7.2.5
symfony/console Version ^7.2
vlucas/phpdotenv Version ^5.6