aludvigsson / youtube-caption-fetcher
A PHP package to fetch captions from YouTube videos
dev-main
2024-08-17 11:35 UTC
Requires
- php: ^7.4|^8.0
- ext-simplexml: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2025-06-08 14:01:41 UTC
README
A PHP package to fetch captions from YouTube videos.
Installation
You can install the package via composer:
composer require aludvigsson/youtube-caption-fetcher
Usage
use Aludvigsson\YouTubeCaptionFetcher\YouTubeCaptionFetcher; use Aludvigsson\YouTubeCaptionFetcher\CaptionFetcherException; use Aludvigsson\YouTubeCaptionFetcher\InvalidUrlException; $fetcher = new YouTubeCaptionFetcher(); try { $transcript = $fetcher->getTranscript('https://www.youtube.com/watch?v=VIDEO_ID'); $title = $fetcher->getVideoTitle('https://www.youtube.com/watch?v=VIDEO_ID'); echo $title; print_r($transcript); } catch (CaptionFetcherException $e) { echo "An error occurred: " . $e->getMessage(); }