Code Monkey home page Code Monkey logo

yii2-youtube-captions-scraper's Introduction

Youtube Scraper

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.

yii2-youtube-captions-scraper's People

Contributors

pazakharov avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.