Sha256: 6160401e68dd7464c5e31fa5fbead38066af60e6ab19a0cebd7db4959eacbf9f
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
module YoutubeDL # Video model class Video < Runner class << self # Instantiate a new Video model and download the video # # @param url [String] URL to use and download # @param options [Hash] Options to pass in # @return [YoutubeDL::Video] new Video model def download(url, options={}) video = new(url, options) video.download video end alias_method :get, :download end # [YoutubeDL::Options] Download Options for the last download attr_reader :download_options # Instantiate new model # # @param url [String] URL to initialize with # @param options [Hash] Options to populate the everything with def initialize(url, options={}) @url = url @options = YoutubeDL::Options.new(options) end # Download the video. def download @download_options = YoutubeDL::Options.new(runner_options) @last_download_output = YoutubeDL::Runner.new(url, @download_options).run end alias_method :get, :download # Returns a list of supported formats for the video in the form of # [{:format_code => '000', :extension => 'avi', :resolution => '320x240', :note => 'More details about the format'}] # # @return [Array] Format list def formats @formats ||= YoutubeDL::Output.new(cocaine_line("--list-formats #{quoted(url)}").run).supported_formats end # @return [String] Filename downloaded to def filename @filename ||= YoutubeDL::Output.new(@last_download_output).filename end private # Add in other default options here. def runner_options { no_color: true }.merge(@options) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
youtube-dl.rb-0.2.0 | lib/youtube-dl/video.rb |