Sha256: c540b828ae4157cc04badeb5ce3d293978760249720d3a9ef61cb96f5ec16a1f
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module YtDlp # # Data model for a video accessed from an URL. # class Video attr_reader :url, :executable_path, :options # Required to get informations about the video. MANDATORY_OPTIONS = { dump_json: true, simulate: false }.freeze # Optimisation purpose. Do not download the video if you only need information. INFORMATION_OPTIONS = MANDATORY_OPTIONS.merge(skip_download: true).freeze # # Initialize a Video. # # # @param [String] url Download URL # @param [Hash] **options See OptionConverter and https://github.com/yt-dlp/yt-dlp # def initialize(url, executable_path = YtDlp.config.executable_path, **options) @url = url @executable_path = executable_path @options = options end def download @information = run_with_options(options.merge(MANDATORY_OPTIONS)) @information[:filename] end def information @information ||= run_with_options(options.merge(INFORMATION_OPTIONS)) end private def run_with_options(options) JSON.parse(run(options), symbolize_names: true) end def run(options) Runner.new(executable_path: executable_path, url: url, options: options).run end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yt_dlp-0.2.0 | lib/yt_dlp/video.rb |
yt_dlp-0.1.1 | lib/yt_dlp/video.rb |