定制 pazakharov/yii2-youtube-captions-scraper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pazakharov/yii2-youtube-captions-scraper

最新稳定版本:v0.0.3

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.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-10