How to get more than 50 videos using youtube api v3 using swift?

0 like 0 dislike
25 views
hi all please tell me how I can get more than 50 videos from youtube playlist

here is my code

import UIKit
import Alamofire

protocol videoModelDelegate{
videoAreReady func()
}

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()
}

}

}

}

}
by | 25 views

1 Answer

0 like 0 dislike
I did upload a video through Google frameworks
pod 'GoogleAPIClientForREST' pod 'GoogleAPIClientForREST/YouTube pod 'Google/SignIn'


Make similar only video.
in Bridging file be SURE to register
#import #import #import 


Break and put code where it should be for you
let service = GTLRYouTubeService() ..... var configureError: NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil, "Error configuring Google services: \\(configureError)") GIDSignIn.sharedInstance().delegate = self GIDSignIn.sharedInstance().uiDelegate = self GIDSignIn.sharedInstance().scopes = [kGTLRAuthScopeYouTube, kGTLRAuthScopeYouTubeUpload] GIDSignIn.sharedInstance().shouldFetchBasicProfile = true GIDSignIn.sharedInstance().signIn() service.authorizer = GIDSignIn.sharedInstance().currentUser.authentication.fetcherAuthorizer() let status = GTLRYouTube_VideoStatus() status.privacyStatus = kGTLRYouTube_VideoStatus_Privacystatus_public let snippet = GTLRYouTube_VideoSnippet() snippet.title = "Lalala" snippet.descriptionProperty = "TestUpload" snippet.tags = "test video upload".components(separatedBy: ",") let youtubeVideo = GTLRYouTube_Video() youtubeVideo.snippet = snippet youtubeVideo.status = status let uploadParams = GTLRUploadParameters(fileURL: url, mimeType: "video/mp4") let uploadQuery = GTLRYouTubeQuery_VideosInsert.query(withObject: youtubeVideo, part: "snippet,status", uploadParameters: uploadParams) uploadQuery.executionParameters.uploadProgressBlock = {(progressTicket, totalBytesUploaded, totalBytesExpectedToUpload) in print("Uploaded", totalBytesUploaded) } service.executeQuery(uploadQuery) { (ticket, obj, error) in print(ticket) print(obj) print(error) }
by

Related questions

0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
32,926 users