Module: HELPEMA::YouTubeDL

Defined in:
lib/helpema/youtubedl.rb

Class Method Summary collapse

Class Method Details

.json(url, pwd = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/helpema/youtubedl.rb', line 6

def self.json(url, pwd=nil)
  Open3.popen2e("youtube-dl -j '#{url}'") do |i, o|
    i.puts pwd if pwd
    i.close
    o.each do |line|
      begin
        yield JSON.parse line
      rescue JSON::ParserError
        yield line
      end
    end
  end
end