youtube-parser

YouTube link parser for swift

Showing:

Popularity

Downloads/wk

0

GitHub Stars

681

Maintenance

Last Commit

5yrs ago

Contributors

8

Package

Dependencies

0

License

MIT

Categories

Readme

YoutubeSourceParserKit

================== Build Status License Dependencies Ready StackOverflow CocoaPods Join the chat at https://gitter.im/mobileplayer/mobileplayer-ios

YouTube Video Link Parser for Swift. Heavily inspried from hellozimi's repo HCYoutubeParser

##Introduction

Requires iOS 8 or later and Xcode 7.0+
Swift support uses dynamic frameworks and is therefore only supported on iOS > 8.

##Installation

To install via CocoaPods add this line to your Podfile.

and

pod 'YoutubeSourceParserKit'

Then, run the following command:

$ pod install

##Usage

import YoutubeSourceParserKit
let testURL = NSURL(string: "https://www.youtube.com/watch?v=swZJwZeMesk")!
    Youtube.h264videosWithYoutubeURL(testURL) { (videoInfo, error) -> Void in
      if let videoURLString = videoInfo?["url"] as? String,
        videoTitle = videoInfo?["title"] as? String {
          print("\(videoTitle)")
          print("\(videoURLString)")
      }
    }
videoInfo output:
{
    "title": "[Video Title]",
    "isStream": 0,
    "quality": "hd720",
    "itag": 22,
    "fallback_host": "tc.v20.cache2.googlevideo.com",
    "url": "http://[Source URL]"
}

##MPMoviePlayerController Usage

alt tag

import UIKit
import YoutubeSourceParserKit
import MediaPlayer

class ViewController: UIViewController {

  let moviePlayer = MPMoviePlayerController()

  override func viewDidLoad() {
    super.viewDidLoad()
    moviePlayer.view.frame = view.frame
    view.addSubview(moviePlayer.view)
    moviePlayer.fullscreen = true
    let youtubeURL = NSURL(string: "https://www.youtube.com/watch?v=swZJwZeMesk")!
    playVideoWithYoutubeURL(youtubeURL)
  }

  func playVideoWithYoutubeURL(url: NSURL) {
    Youtube.h264videosWithYoutubeURL(url, completion: { (videoInfo, error) -> Void in
      if let
        videoURLString = videoInfo?["url"] as? String,
        videoTitle = videoInfo?["title"] as? String {
          self.moviePlayer.contentURL = NSURL(string: videoURLString)
      }
    })
  }
}

Warning: This repo is for educational purposes. This is not approved by the ToC of YouTube. Use at own risk.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100