Created
March 21, 2024 19:05
-
-
Save MrWeb/2d49bb38188aaec6f3c5c5a3357355ef to your computer and use it in GitHub Desktop.
Extract text and captions from a Youtube Video with PHP and Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Http; | |
$videoId = "AuEv942wOZs"; | |
$transcriptUrl = Http::post( | |
"https://youtubei.googleapis.com/youtubei/v1/player", | |
[ | |
"videoId" => $videoId, | |
"context" => [ | |
"client" => [ | |
"hl" => "en", | |
"clientName" => "WEB", | |
"clientVersion" => "2.20210721.00.00" | |
] | |
] | |
] | |
)->json("captions.playerCaptionsTracklistRenderer.captionTracks.0.baseUrl"); | |
$transcriptXml = Http::post($transcriptUrl, [ | |
"videold" => $videoId | |
])->body(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment