Sha256: 719c39e94bd75db078ff508cb55808f70598e574c5f00453d31862bb71b5195f

Contents?: true

Size: 1.31 KB

Versions: 44

Compression:

Stored size: 1.31 KB

Contents

require 'cocaine'
require 'json'
require 'ostruct'

require 'youtube-dl/version'
require 'youtube-dl/support'
require 'youtube-dl/options'
require 'youtube-dl/runner'
require 'youtube-dl/video'

# Global YoutubeDL module. Contains some convenience methods and all of the business classes.
module YoutubeDL
  extend self
  extend Support

  # Downloads given array of URLs with any options passed
  #
  # @param urls [String, Array] URLs to download
  # @param options [Hash] Downloader options
  # @return [YoutubeDL::Video, Array] Video model or array of Video models
  def download(urls, options = {})
    if urls.is_a? Array
      urls.map { |url| YoutubeDL::Video.get(url, options) }
    else
      YoutubeDL::Video.get(urls, options) # Urls should be singular but oh well. url = urls. There. Go cry in a corner.
    end
  end

  alias_method :get, :download

  # Lists extractors
  #
  # @return [Array] list of extractors
  def extractors
    @extractors ||= cocaine_line('--list-extractors').run.split("\n")
  end

  # Returns youtube-dl's version
  #
  # @return [String] youtube-dl version
  def binary_version
    @binary_version ||= cocaine_line('--version').run.strip
  end

  # Returns user agent
  #
  # @return [String] user agent
  def user_agent
    @user_agent ||= cocaine_line('--dump-user-agent').run.strip
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
youtube-dl.rb-0.3.1.2016.06.26 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.06.25 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.06.23 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.06.20 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.06.19.1 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.06.16 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.06.16 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.06.14 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.06.03 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.06.02 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.05.21.2 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.05.16 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.05.01 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.04.24 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.04.19 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.04.13 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.04.06 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.04.01 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.03.27 lib/youtube-dl.rb
youtube-dl.rb-0.3.0.2016.03.25 lib/youtube-dl.rb