@@ -8,10 +8,11 @@ struct Video {
88 var width : CGFloat
99 var height : CGFloat
1010 var length : Double
11- var cdn : String
1211 var captions : [ Caption ]
1312 var libraryId : Int
1413 let resolutions : [ Resolution ]
14+ var seekPath : String ?
15+ var playlistUrl : String ?
1516}
1617
1718extension Video {
@@ -29,18 +30,22 @@ extension Video {
2930 }
3031
3132 func seekThumbnailURLs( thumbnailsPerImage: Int ) -> [ URL ] {
33+ guard let seekPath = seekPath else { return [ ] }
3234 let numberOfPreviews = Int ( ceil ( Double ( thumbnailCount) / Double( thumbnailsPerImage) ) )
33- return ( 0 ..< numberOfPreviews) . compactMap {
34- URL ( string: " https:// \( cdn ) / \( guid ) /seek/ _\( $0 ) .jpg " )
35+ return ( 0 ..< numberOfPreviews) . compactMap { index in
36+ URL ( string: " \( seekPath ) / _\( index ) .jpg " )
3537 }
3638 }
3739}
3840
3941extension Video {
40- init ( videoConfigResponse: VideoConfigResponse . Video , cdn: String ) {
42+ init ( response: VideoConfigResponse ) {
43+ let videoConfigResponse = response. video
4144 let chapters = videoConfigResponse. chapters. map { Chapter ( start: Double ( $0. start) , end: Double ( $0. end) , type: . regular( title: $0. title) ) }
4245 let moments = videoConfigResponse. moments. map { Moment ( label: $0. label, second: $0. timestamp) }
43- let captions = videoConfigResponse. captions. map { Caption ( languageCode: $0. srclang, label: $0. label) }
46+ let captions = videoConfigResponse. captions. map {
47+ Caption ( languageCode: $0. srclang, label: $0. label, captionsPath: response. captionsPath)
48+ }
4449
4550 var computedResolutions = [ Video . Resolution. auto]
4651 let resolutionStrings = videoConfigResponse. availableResolutions. split ( separator: " , " )
@@ -51,17 +56,20 @@ extension Video {
5156 }
5257 computedResolutions. sort { $0. bitrate < $1. bitrate }
5358
54- self . init ( guid: videoConfigResponse. guid,
55- chaptersList: ValidatedChapterList ( originalChapters: chapters, duration: videoConfigResponse. length) ,
56- moments: moments,
57- thumbnailCount: videoConfigResponse. thumbnailCount,
58- width: CGFloat ( videoConfigResponse. width) ,
59- height: CGFloat ( videoConfigResponse. height) ,
60- length: videoConfigResponse. length,
61- cdn: cdn,
62- captions: captions,
63- libraryId: videoConfigResponse. videoLibraryId,
64- resolutions: computedResolutions)
59+ self . init (
60+ guid: videoConfigResponse. guid,
61+ chaptersList: ValidatedChapterList ( originalChapters: chapters, duration: videoConfigResponse. length) ,
62+ moments: moments,
63+ thumbnailCount: videoConfigResponse. thumbnailCount,
64+ width: CGFloat ( videoConfigResponse. width) ,
65+ height: CGFloat ( videoConfigResponse. height) ,
66+ length: videoConfigResponse. length,
67+ captions: captions,
68+ libraryId: videoConfigResponse. videoLibraryId,
69+ resolutions: computedResolutions,
70+ seekPath: response. seekPath,
71+ playlistUrl: response. videoPlaylistUrl
72+ )
6573 }
6674
6775 mutating func adjustLength( _ length: Double ? ) {
0 commit comments