TVUploader 0.1.2

TVUploader 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2016
SPMSupports SPM

Maintained by noppefoxwolf.



 
Depends on:
STTwitter>= 0
SwiftTask>= 0
Unbox>= 0
 

  • By
  • Tomoya Hirano

TVUploader

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

TVUploader is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TVUploader"

Usage

Print the video information

    let videoUrl1 = NSBundle.mainBundle().URLForResource("sample1", withExtension: "mp4")!
    let info1 = TVVideoInfo(videoUrl: videoUrl1)
    print(info1)

infomation example

---- Video Track Infomation ---
File Path: file://TVUploader_Example.app/sample.mp4
Duration:  2.83182222222222sec
File Size: 0.0930662MB (97587B)
Dimension: 320.0 x 180.0 [width x height]
Aspect Ratio: 1.77778
Channel Count: 2
FPS: 24.0128
--------------------------

Video format validation for Twitter

    TVValidater(videoInfo: info1, postType: .Async).validationCheckTask().success { (safes) in
        print(safes)
      }.failure { (error, isCancelled) in
        print(error)
    }

validation result example of success

[TVUploader.TVValidater.FormatValid.durationValid, TVUploader.TVValidater.FormatValid.fileSizeValid, TVUploader.TVValidater.FormatValid.dimensionsValid, TVUploader.TVValidater.FormatValid.aspectRatioValid, TVUploader.TVValidater.FormatValid.frameRateValid, TVUploader.TVValidater.FormatValid.audioChannelValid, TVUploader.TVValidater.FormatValid.audioFormatValid]

validation result example of failure It will be called at the time verification fails.

Optional(TVUploader.TVValidater.FormatError.InvalidDuration)

post video to twitter

Supports synchronous and asynchronous(chunked) upload.

    let api = TVUploaderAPI(OAuthConsumerKey: "",
                           consumerSecret: "",
                           oauthToken: "",
                           oauthTokenSecret: "")
    api.asyncVideoUpload(videoUrl1).success { (mediaId) -> TVUploaderAPI.PostTask in
      return api.postStatusUpdateTask("", mediaId: mediaId)
    }.success { (_) in
      print("video1 upload success")
    }.failure { (error, isCancelled) in
      print("video1 upload failure")
    }

TODO

  • [ ] upload progress
  • [ ] video File Optimizer
  • [ ] open GOP validater
  • [ ] progressive scan validater
  • [ ] pixel aspect ratio validater
  • [ ] audio channels validater
  • [ ] audio format validater
  • [ ] git support
  • [ ] image support

Author

Tomoya Hirano, [email protected]

License

TVUploader is available under the MIT license. See the LICENSE file for more info.