|
|
# YouTubeUploader
|
|
|
|
|
|
## Auth
|
|
|
|
|
|
```swift
|
|
|
YouTubeUploader.auth { response in
|
|
|
switch response {
|
|
|
case .deviceCode(let userCode, let verificationUrl):
|
|
|
self.infoLabel.text = "VISIT\n\(verificationUrl.uppercased())\nAND ENTER\n\(userCode.uppercased())"
|
|
|
|
|
|
case .ready, .readyWithoutToken:
|
|
|
self.authorized()
|
|
|
|
|
|
case .error:
|
|
|
self.infoLabel.text = "YOUTUBE AUTH ERROR"
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## Upload
|
|
|
|
|
|
```swift
|
|
|
YouTubeUploader.upload(title: title, file: session.videoUrl) { id in
|
|
|
if let id = id {
|
|
|
session.videoYoutubeLink = "https://youtu.be/" + id
|
|
|
CoreData.save()
|
|
|
completionHandler(true)
|
|
|
} else {
|
|
|
completionHandler(false)
|
|
|
}
|
|
|
}
|
|
|
``` |