Repository navigation
Update for latest changes by YouTube for video extraction.
- Fixed local signature solving for YouTube's latest player changes thanks to @urshofer
- Added
availableAtandwaitUntilAvailable()toStreamfor videos with preroll ads
Waiting for preroll ads
For videos with preroll ads, YouTube only serves the stream URL after a short waiting period, usually a few seconds. Requesting the URL earlier can fail with 403 for the lifetime of that URL.
Call waitUntilAvailable() before playing or downloading a stream:
let stream = try await YouTube(videoID: "QdBZY2fkU-0").streams
.filterVideoAndAudio()
.filter { $0.isNativelyPlayable }
.highestResolutionStream()
if let stream {
try await stream.waitUntilAvailable()
let player = AVPlayer(url: stream.url)
}waitUntilAvailable() returns immediately if the stream is already available. If you want to handle the wait yourself, for example to show a loading state, check stream.availableAt directly.