Releases: alexeichhorn/YouTubeKit
0.2.4
0.2.3
Fixed an issue where some video streams returned a 403 error when trying to download
0.2.2
fixed an issue where some videos were not playable
0.2.1
Fixes for rare stream extraction issues
0.2
The biggest update so far:
Native Playable Streams
Playing a YouTube video stream or audio stream in AVPlayer always comes with the challenge of filtering the stream urls that are actually natively supported by the current operating system. This has now become a built-in feature in YouTubeKit:
Every Stream
now has an isNativelyPlayable
property. It is true if the codecs of the stream are supported by the current OS & device running the code.
If you want to play a video in AVPlayer, you can now simply do:
let stream = try await YouTube(videoID: "QdBZY2fkU-0").streams
.filterVideoAndAudio()
.filter { $0.isNativelyPlayable }
.highestResolutionStream()
let player = AVPlayer(url: stream!.url)
// -> Now, present the player however you like
Metadata (thx @waliid)
Get metadata of a YouTube video directly in YouTubeKit by simply calling:
let metadata = try await video.metadata
This returns a metadata object with video title, description, and thumbnails.
Experimental: Remote Extraction Fallback
With local YouTube extractors, there is the problem that YouTube might suddenly change their unofficial API, which can break your existing shipped app. Now, there is an option to activate a fallback that calls a server running a modified version of youtube-dl
, which performs the latest extraction formula via the running device. Read more here.
You can activate it by simply adding a .remote
method like this:
let streams = try await YouTube(videoID: "2lAe1cqCOXo", methods: [.local, .remote]).streams
Video & Audio Codecs
Streams now have fully type-safe video & audio codec properties. You can easily filter streams by codec:
// filter by the AV1 codec
streams.filter { $0.videoCodec == .av1 }
// filter by video & audio codec
streams.filter { $0.videoCodec == .av1 && $0.audioCodec == .mp4a }
Additional Changes
- More robust extraction methods: Fixes cases where there were no streams with both audio & video included.
- New type-safe
fileExtension
property inStream
. E.g., filter by webm files:streams.filter { $0.fileExtension == .webm }
- The properties
type
andsubtype
are deprecated. They will be empty when using the new remote extraction method. UsefileExtension
,videoCodec
, andaudioCodec
instead. - New supported formats, such as HLS streams or surround sound.
- New filtering functions on
[Stream]
:streams.filter(byResolution: $0 >= 1080 && $0 <= 2160)
, to filter by your custom resolution requirements.streams.filterAudioAndAudio()
, only returns streams which contain both audio and video track. Equivalent but more readable version ofstreams.filter { $0.isProgressive }
.
Full Changelog: 0.1.9...0.2
0.1.9
0.1.8
Fixed extraction of most videos
0.1.7
Fixes crash when extracting some videos
0.1.6
Made YouTubeKitError
public with additional user-facing descriptions
0.1.5
Fixed extraction of age restricted videos