Youtube-Data-Api-V3未列出参数

时间:2018-02-19 09:09:27

标签: ios swift youtube-data-api

如何将视频上传为不公开?我想将视频上传为不公开的视频。我添加了剪切到多形式数据以发送标题和描述

但我不知道如何将视频上传为不公开。

**这里是我的代码:**

func postVideoToYT(videoUrl: URL, token: String,title:String,innoId:Int,videoTags:String,callback: @escaping (Bool) -> Void) {
        do {
            let headers = ["Authorization": "Bearer \(token)"]
            let videoData = try Data(contentsOf: videoUrl)
            upload(multipartFormData: { multipartFormData in
                multipartFormData.append("{'snippet':{'title' : '\(title)', 'description': ''}}".data(using: String.Encoding.utf8, allowLossyConversion: false)!, withName: "snippet", mimeType: "application/json")
                multipartFormData.append(videoData, withName: "video", fileName: "video.mp4", mimeType: "application/octet-stream")
            }, usingThreshold: 1, to: URL(string: "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet")!, method: .post, headers: headers, encodingCompletion: { encodingResult in
                switch encodingResult {
                case .success(let upload, _, _):

                    upload.responseJSON { response in
                        print("Post video to url --->\(response)")
                        if let json = response.result.value as? [String : Any] {
                            let videoId = json["id"] as! String
                            self.delayWithSeconds(1, completion: {
                                self.addVideo(innoId: innoId, videoKey:videoId, shortDesc: title, tagIds: videoTags)
                            })
                        }

                        callback(true)
                    }

                    upload.uploadProgress(closure: { (progress) in
                        self.progressView.progress = Float(progress.fractionCompleted)
                        self.progressLabel.text = "\(( Int(progress.fractionCompleted * 100)))%"
                    })

                    break
                case .failure(_):
                    callback(false)
                    break
                }
            })
        }

        catch {
        }
    }

请提供任何建议或示例代码?

如何将状态添加到我的代码段?

vm.metaData = {
      snippet: {
        title: '********',
        description: '************',
        tags: ['*******'],
        categoryId: 1
      },
      status: {
        privacyStatus: 'unlisted'
      }
    }

0 个答案:

没有答案