Skip to content

boonstoppel/youtube-transcript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Usage

Basic Usage

To use the YoutubeTranscript package, create a new instance of the class by passing the YouTube video ID.

use boonstoppel\YoutubeTranscript\YoutubeTranscript;

$videoId = 'your-youtube-video-id';
$translateLang = 'en';

$yt = new YoutubeTranscript($videoId);

$data = [
    'original' => $yt->fetchTranscriptData(),
    'translated' => $yt->fetchTranscriptData($translateLang)
];

Or with dependency injection:

use App\Http\Controllers\Controller;
use boonstoppel\YoutubeTranscript\YoutubeTranscript;

class TranscriptController extends Controller
{
    public function __invoke(YoutubeTranscript $yt)
    {
        $yt->videoId = 'YOUR_VIDEO_ID';

        return [
            'original' => $yt->fetchTranscriptData(),
            'translated' => $yt->fetchTranscriptData(request('translate_lang'))
        ];
    }
}

About

A laravel library to fetch youtube video transcripts from the youtube API V3. https://developers.google.com/youtube/v3/docs/captions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages