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.09.11.1 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.31 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.28 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.19 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.13 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.12 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.10 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.07 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.06 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.08.01 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.30 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.26.2 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.24 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.22 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.13 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.11 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.09.1 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.03 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.07.01 lib/youtube-dl.rb
youtube-dl.rb-0.3.1.2016.06.27 lib/youtube-dl.rb