Skip to content

Commit 76d3f34

Browse files
committed
feat: add new timeLenghtSeconds property to YTVideo
1 parent 8c0938b commit 76d3f34

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Sources/YouTubeKit/BaseStructs/YTVideo.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ public struct YTVideo: YTSearchResult, YouTubeVideo, Codable, Sendable {
171171
/// Can be `live` instead of `ab:cd` if the video is a livestream.
172172
public var timeLength: String?
173173

174+
/// Length in seconds of the video, extracted from ``timeLength``.
175+
public var timeLenghtSeconds: Int? {
176+
if let timeLength {
177+
return Self.timeStringToSeconds(timeLength)
178+
}
179+
return nil
180+
}
181+
174182
/// Array of thumbnails.
175183
///
176184
/// Usually sorted by resolution, from low to high.

Sources/YouTubeKit/YouTubeResponseTypes/VideoInfos/VideoInfosResponse.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public struct VideoInfosResponse: YouTubeResponse {
9090
public var aspectRatio: Double?
9191

9292
/// The start time of the video in seconds, represents the time that was already partially watched or that the "t" parameter is set in the video URL. Currently disabled because we can't make VideoInfosResponse requests with cookies.
93+
///
94+
/// - Note: This property is also available on ``YTVideo/startTime``, please use this value.
9395
//public var startTime: Int? = nil
9496

9597
/// Array of formats used to download the video, they usually contain both audio and video data and the download speed is higher than the ``VideoInfosResponse/downloadFormats``.

0 commit comments

Comments
 (0)