Class: Autoaudio::Cli::Application

Inherits:
Thor
  • Object
show all
Defined in:
lib/autoaudio/cli/application.rb

Instance Method Summary collapse

Instance Method Details

#destroy_feedsObject



28
29
30
# File 'lib/autoaudio/cli/application.rb', line 28

def destroy_feeds
  Feed.each { |f| f.destroy }
end

#display_configuration_settingsObject



8
9
10
11
12
13
14
15
# File 'lib/autoaudio/cli/application.rb', line 8

def display_configuration_settings
  puts "Autoaudio::VERSION = #{Autoaudio::VERSION}"
  puts "Download location = #{Autoaudio::Config::NZB_DOWNLOAD_LOCATION[:directory]}"
  puts "Tweet = #{Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs]}"
  if Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs] == true
    puts "Twitter Username = #{Autoaudio::Config::TWITTER_SETTINGS[:username]}"
  end
end

#display_feedsObject



23
24
25
# File 'lib/autoaudio/cli/application.rb', line 23

def display_feeds
  Feed.each { |f| pp f }
end

#downloadObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/autoaudio/cli/application.rb', line 33

def download
  Feed.make
  feeds = Feed.where(downloaded: false).each.to_a
  i = (feeds.length / 5)
  while i > 0
    new_array = Array.new
    5.times do
      new_array << feeds.pop
    end
    new_array.each { |feed| Download.album(feed) }
    sleep 20
    i -= 1
  end
  unless File.zero?('./log/gist.txt')
    system("gist -c -p -d \"#{DateTime.now}\" -f \"#{DateTime.now}\" './log/gist.txt' -f download.thor './etc/download.thor'")
    if Autoaudio::Config::TWITTER_SETTINGS[:tweet_nzbs] == true
      system("t set active #{Autoaudio::Config::TWITTER_SETTINGS[:username]}")
      system("t update `pbpaste`")
    end
  end
  File.truncate('./log/gist.txt', 0)
end

#download_genre(genre_formatted) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/autoaudio/cli/application.rb', line 57

def download_genre(genre_formatted)
  genre = Feed.where(
    # audio_format: "MP3",
    genre_formatted: genre_formatted,
    nzb_opened: false
  )
  genre.each do |feed|
    if feed.nzb != nil
      system("open #{feed.nzb}")
      feed.update_attribute(:nzb_opened, true)
    end
  end
end

#make_feedsObject



18
19
20
# File 'lib/autoaudio/cli/application.rb', line 18

def make_feeds
  Feed.make
end