всем Привет подскажите пожалуйста как я могу получить более 50 видео с плейлиста youtube
вот мой код
import UIKit
import Alamofire
protocol videoModelDelegate{
func videoAreReady()
}
class VideoModel: NSObject {
private var API_KEY = "----"
private var urlString = "
https://www.googleapis.com/youtube/v3/playlistItems"
private var playlistID = "PLUumXRq81CH-wZh0vgWDP-Eoi3mzB8nUa"
var delegate: videoModelDelegate!
var video = [Video]()
func getVideo(){
Alamofire.request(urlString, method: .get, parameters: ["part":"snippet", "key":API_KEY, "playlistId":playlistID, "maxResults":"50",], encoding: URLEncoding.default, headers: nil).responseJSON { (response) in
if let JSON = response.value as? [String:Any]{
var arrayOfTheVideo = [Video]()
for video in JSON["items"] as! NSArray {
let videoObject = Video()
videoObject.videoId = (video as! NSDictionary).value(forKeyPath: "snippet.resourceId.videoId") as! String
videoObject.videoTitle = (video as! NSDictionary).value(forKeyPath: "snippet.title") as! String
videoObject.videoDescription = (video as! NSDictionary).value(forKeyPath: "snippet.description") as! String
if (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.maxres.url") != nil{
videoObject.videoThumbnailUrl = (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.maxres.url") as! String
}else if (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.hqdefault.url") != nil{
videoObject.videoThumbnailUrl = (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.hqdefault.url") as! String
}else if (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.sddefault.url") != nil{
videoObject.videoThumbnailUrl = (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.sddefault.url") as! String
}else if (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.mqdefault.url") != nil{
videoObject.videoThumbnailUrl = (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.mqdefault.url") as! String
}else if (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.default.url") != nil{
videoObject.videoThumbnailUrl = (video as! NSDictionary).value(forKeyPath: "snippet.thumbnails.default.url") as! String
}else{
}
arrayOfTheVideo.append(videoObject)
}
self.video = arrayOfTheVideo
if self.delegate != nil{
self.delegate!.videoAreReady()
}
}
}
}
}