pazakharov/yii2-youtube-captions-scraper
Composer 安装命令:
composer require pazakharov/yii2-youtube-captions-scraper
包简介
Youtube captions (subtitles) scraper
README 文档
README
The Youtube Scraper is a PHP package that allows you to scrape captions and subtitles from Youtube videos. It uses the Yii 2 framework and the Guzzle HTTP client to make requests to the Youtube API.
Installation
You can install the Youtube Scraper using Composer:
composer require pazakharov/yii2-youtube-captions-scraper
Usage
To use the Youtube Scraper, you first need to create an instance of the YoutubeScraper class and set the languageCode property to the language code of the captions you want to scrape. You can then use the getCaptionsBaseUrl and getSubtitles methods to retrieve the base URL and subtitles, respectively.
Here's an example usage:
use Zakharov\YoutubeScraper; $scraper = Yii::createObject([ 'class' => YoutubeScraper::class, ]); $captionUrl = $scraper->getCaptionsBaseUrl('https://www.youtube.com/watch?v=wNzql5TZ-i'); $subtitles = $scraper->getSubtitles($captionUrl);
In this example, we're scraping the captions (subtitles) for the video with the ID wNzql5TZ-i. The getCaptionsBaseUrl method returns the base URL for the captions, which we then pass to the getSubtitles method to retrieve the subtitles.
Note that the getSubtitles method returns an array of strings, where each string represents a subtitle. You can then use this array to display the subtitles in your application.
For use proxy use .env var HTTPCLIENT_PROXY=http://login:password@domain:port or you can configure and provide own instance of Client to YoutubeScraper class.
Testing and Contributing
The Youtube Scraper includes a test suite to ensure that it works correctly. You can run the tests using the phpunit command:
vendor/bin/codecept run unit
This will run the test suite and output the results.
The Youtube Scraper follows the PSR-2 coding standards. You can check the code for compliance using the phpcs command:
composer check-code
Fix code by phpcbf
composer fix-code
License The Youtube Scraper is licensed under the MIT license. You can use it free of charge and without any restrictions.
pazakharov/yii2-youtube-captions-scraper 适用场景与选型建议
pazakharov/yii2-youtube-captions-scraper 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 01 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 pazakharov/yii2-youtube-captions-scraper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pazakharov/yii2-youtube-captions-scraper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-10