Sha256: f9560977ef13c157d77f0176f10272807da9fdf7b44dc08e708887ab4c665fc5

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'cocaine'

require 'youtube-dl/version'
require 'youtube-dl/support'
require 'youtube-dl/options'
require 'youtube-dl/output'
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
  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

4 entries across 4 versions & 1 rubygems

Version Path
youtube-dl.rb-0.2.2.2015.10.16 lib/youtube-dl.rb
youtube-dl.rb-0.2.2.pre.2015.10.12 lib/youtube-dl.rb
youtube-dl.rb-0.2.2 lib/youtube-dl.rb
youtube-dl.rb-0.2.1 lib/youtube-dl.rb