Class: MyShows::CLI
- Inherits:
-
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
.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
|
.logger ⇒ Object
24
25
26
|
# File 'lib/my_shows.rb', line 24
def logger
MyShows.logger
end
|
.lookup_magnet_links(shows) ⇒ Object
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
|
.print_episodes(episodes) ⇒ Object
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
puts 'Bye!'
end
|
56
57
58
|
# File 'lib/my_shows.rb', line 56
def
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)
configure_client
shows = Show.next_episodes
links = lookup_magnet_links(shows)
print_episodes shows
enque_to_download links
end
|