Class: MyShows::CLI

Inherits:
Object
  • Object
show all
Extended by:
Auth
Defined in:
lib/my_shows.rb

Class Method Summary collapse

Methods included from Auth

ask, ask_for_and_save_credentials, ask_for_credentials, ask_for_password, check, credentials, delete_credentials, echo_off, echo_on, host, netrc, read_credentials, with_tty, write_credentials

Class Method Details

.configure_clientObject



28
29
30
# File 'lib/my_shows.rb', line 28

def configure_client
  MyShows::Show.client = SidereelClient.new(*self.credentials)
end

.enque_to_download(links) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/my_shows.rb', line 38

def enque_to_download(links)
  links.each do |link|
    logger.info "Enque #{URI(link).to_s}"
    sleep 5
    Launchy::Application::General.new.open([URI(link).to_s])
  end
end

.loggerObject



24
25
26
# File 'lib/my_shows.rb', line 24

def logger
  MyShows.logger
end


32
33
34
35
36
# File 'lib/my_shows.rb', line 32

def lookup_magnet_links(shows)
  shows.map { |show|
    show.episode.torrent_link!
  }.compact
end


60
61
62
63
64
65
66
# File 'lib/my_shows.rb', line 60

def print_episodes episodes
  puts 'Next episodes:'
  episodes.each do |show|
    episode = show.episode
    puts "#{episode} [#{episode.magnet_link ? ''.colorize(:green) : ''.colorize(:red)}]"
  end
end


68
69
70
# File 'lib/my_shows.rb', line 68

def print_footer
  puts 'Bye!'
end


56
57
58
# File 'lib/my_shows.rb', line 56

def print_header
  puts "MyShows #{MyShows::VERSION}".colorize(:light_white)
end

.start(*args) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/my_shows.rb', line 46

def start(*args)
  print_header
  configure_client
  shows = Show.next_episodes
  links = lookup_magnet_links(shows)
  print_episodes shows
  enque_to_download links
  print_footer
end