class AudioAddict::Youtube
Attributes
query[R]
Public Class Methods
new(query)
click to toggle source
# File lib/audio_addict/youtube.rb, line 8 def initialize(query) @query = query end
Public Instance Methods
command(args)
click to toggle source
# File lib/audio_addict/youtube.rb, line 22 def command(args) command_template % args end
get(count = 1)
click to toggle source
# File lib/audio_addict/youtube.rb, line 16 def get(count = 1) raise DependencyError, "This command requires youtube-dl" unless command_exist? 'youtube-dl' success = execute command(count: count, query: query) raise DependencyError, "youtube-dl exited with an error" unless success end
inspectable()
click to toggle source
# File lib/audio_addict/youtube.rb, line 12 def inspectable [:query] end
Private Instance Methods
command_template()
click to toggle source
# File lib/audio_addict/youtube.rb, line 37 def command_template @command_template ||= %Q[youtube-dl --extract-audio --audio-format mp3 ytsearch%{count}:"%{query}"] end
execute(command)
click to toggle source
# File lib/audio_addict/youtube.rb, line 28 def execute(command) if ENV['AUDIO_ADDICT_DOWNLOAD_DRY_RUN'] puts "DRY RUN: #{command}" true else system command end end