Class: DownloadTV::Torrent
- Inherits:
-
Object
- Object
- DownloadTV::Torrent
- Defined in:
- lib/download_tv/torrent.rb
Overview
Class in charge of managing the link grabbers
Class Method Summary collapse
Instance Method Summary collapse
- #get_links(show) ⇒ Object
-
#initialize(default_grabber = nil) ⇒ Torrent
constructor
A new instance of Torrent.
Constructor Details
#initialize(default_grabber = nil) ⇒ Torrent
Returns a new instance of Torrent.
20 21 22 23 24 25 26 27 |
# File 'lib/download_tv/torrent.rb', line 20 def initialize(default_grabber = nil) @g_instances = self.class.grabbers\ .rotate(self.class.grabbers.find_index(default_grabber) || 0) .map { |g| (DownloadTV.const_get g).new } reset_tries remove_grabber_if_offline end |
Class Method Details
.grabbers ⇒ Object
8 9 10 |
# File 'lib/download_tv/torrent.rb', line 8 def grabbers %w[Torrentz ThePirateBay Eztv] end |
.healthcheck ⇒ Object
12 13 14 15 16 17 |
# File 'lib/download_tv/torrent.rb', line 12 def healthcheck grabbers.each do |g| grabber = (DownloadTV.const_get g).new puts "#{g}: #{grabber.online? ? 'online' : 'offline'}" end end |
Instance Method Details
#get_links(show) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/download_tv/torrent.rb', line 29 def get_links(show) @g_instances.first.get_links(show) rescue NoTorrentsError if @tries.positive? change_grabbers retry end # We're out of grabbers to try puts "No torrents found for #{show}" [] ensure reset_grabbers_order end |