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
44
45
46
47
48
49
50
51
|
# File 'lib/my_shows.rb', line 44
def enque_to_download(links)
links.each do |link|
sleep 5
uri = URI(link).to_s
logger.info "Enque #{uri}"
Launchy::Application::General.new.open([uri])
end
end
|
.logger ⇒ Object
22
23
24
|
# File 'lib/my_shows.rb', line 22
def logger
MyShows.logger
end
|
.lookup_magnet_links(shows) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/my_shows.rb', line 30
def lookup_magnet_links(shows)
shows.pmap do |show|
link = show.episode.torrent_link!
if link
logger.debug "Found #{link[0...10]} for #{show.name}!"
else
logger.debug "Not Found any links for #{show.name}!"
end
link
end.compact
end
|
.print_episodes(episodes) ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/my_shows.rb', line 70
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
|
78
79
80
|
# File 'lib/my_shows.rb', line 78
def
puts 'Bye!'
end
|
66
67
68
|
# File 'lib/my_shows.rb', line 66
def
puts "MyShows #{MyShows::VERSION}".colorize(:light_white)
end
|
.start(*args) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/my_shows.rb', line 53
def start(*args)
configure_client
shows = Show.next_episodes
links = lookup_magnet_links(shows)
print_episodes shows
enque_to_download links
end
|