class AudioAddict::Commands::DownloadCmd

Public Instance Methods

current_command() click to toggle source
# File lib/audio_addict/commands/download.rb, line 29
def current_command
  needs :network, :channel

  say "!txtblu!Downloading !txtrst!: ... "

  track = current_channel.current_track
  query = track.search_string

  resay "!txtblu!Downloading !txtgrn!: #{query}"

  Youtube.new(query).get count
end
log_command() click to toggle source
# File lib/audio_addict/commands/download.rb, line 42
def log_command
  needs :like_log
  lines = args['--lines']&.to_i

  data = log.data[-lines..-1]
  data.each do |line|
    network, channel, artist, song = line.split(" :: ")
    query = "#{artist}, #{song}"
    say "\n!txtblu!Downloading !txtgrn!: #{query}"
    Youtube.new(query).get count
  end
end
search_command() click to toggle source
# File lib/audio_addict/commands/download.rb, line 55
def search_command
  query = args['QUERY']

  say "\n!txtblu!Downloading !txtgrn!: #{query}"
  Youtube.new(query).get count
end

Private Instance Methods

count() click to toggle source
# File lib/audio_addict/commands/download.rb, line 64
def count
  args['--count']&.to_i || ENV['AUDIO_ADDICT_DOWNLOAD_COUNT']&.to_i || 1
end
log() click to toggle source
# File lib/audio_addict/commands/download.rb, line 68
def log
  @log ||= Log.new
end