GithubHelp home page GithubHelp logo

youtubesourceparserkit's Introduction

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.

use_frameworks!

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.

youtubesourceparserkit's People

Contributors

bitdeli-chef avatar cemolcay avatar hirohisa avatar readmecritic avatar toshi0383 avatar toygar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtubesourceparserkit's Issues

not working with AVPlayerViewController

let playerViewController:AVPlayerViewController = AVPlayerViewController()
    let youtubeUrl = NSURL(string: "https://www.youtube.com/watch?v=vXjVFPosQHw")!
    Youtube.h264videosWithYoutubeURL(youtubeUrl) { [unowned self] (videoInfo, error) -> Void in
        if let videoURLString = videoInfo?["url"] as? String,
            videoTitle = videoInfo?["title"] as? String {
                print("\(videoTitle)")
                print("\(videoURLString)")

                if let url = NSURL(string:videoURLString) {
                    let playerItem = AVPlayerItem(URL: url)
                    let player = AVPlayer(playerItem: playerItem)
                    self.playerViewController.player = player;
                    self.addChildViewController(self.playerViewController);
                    self.playerViewController.view.frame = self.view.frame;
                    self.view.addSubview(self.playerViewController.view);
                    player.play()
                }
        }
    }
}

When the AVPlayerViewController is added to the view, it show a video as unplayable

img

Version Support For Swift 3 - Xcode 8.3.3

Dear team,

Urgently we are really need this library to support Xcode 8.3.3 for Swift 3, what version should we use ? For the latest tag, 0.2.4 is still not support for swift 3.

Thanks.

Video quality

Is there any chance to get the video file with a quality higher than 720p?

Can't playing "video/webm".

This is the video link details after parsing:-

["title": TEST VIDEO, "isStream": 0, "quality": medium, "itag": 43, "fallback_host": redirector.googlevideo.com, "url": http://r2---sn-ugp2ax2a5t-qxal.googlevideo.com/videoplayback?signature=9BAF291E3045E666CC644B79E4DE08A3F38B4290.69C7A2A5159E3A14F66519940B220F4DED5D1A4E&lmt=1298445916327233&sparams=dur%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Csource%2Cupn%2Cexpire&initcwndbps=2517500&id=o-AEqjkthPJ1gDlZ8RJCiPgRdzZm4hItkkpyuOJ7eHPm3_&ip=150.242.64.105&dur=0.000&mm=31&mn=sn-ugp2ax2a5t-qxal&pl=24&expire=1482579910&ms=au&ipbits=0&ratebypass=yes&mv=m&mt=1482558095&key=yt6&source=youtube&mime=video%2Fwebm&itag=43&upn=pTMlflFXXV8, "type": video/webm; codecs="vp8.0, vorbis"]

Unable to install by Cocoapods

Podfile:

platform :ios, '7.0'
pod "youtube-parser", :git => 'https://github.com/toygard/youtube-parser.git'

Error:
pod install
Updating local specs repositories

CocoaPods 0.39.0.beta.3 is available.
To update use: sudo gem install cocoapods --pre
[!] This is a test version we'd love you to try.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Pre-downloading: youtube-parser from https://github.com/toygard/youtube-parser.git
[!] Unable to satisfy the following requirements:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.