class DownloadTV::KAT

KATcr.co grabber
#

def get_links(show)

def get_links(show)
  tries = 0
  params = {
    'category': 'TV',
    'orderby': 'seeds-desc',
    'search': show
  }
  data = @agent.post(@url, params)
               .search('tbody tr td[1]')
  names = data.map do |i|
    i.search('a.torrents_table__torrent_title b')
     .text
  end
  links = data.map do |i|
    i.search('div.torrents_table__actions a[3]')
     .first
     .attribute('href')
     .text
  end
  raise NoTorrentsError if data.empty?
  names.zip(links)
rescue Net::HTTP::Persistent::Error => e
  raise unless e.message =~ /too many connection resets/
  raise if tries >= @max_tries
  tries += 1
  retry
end

def initialize

def initialize
  super('https://katcr.co/advanced-usearch/')
  @max_tries = 5
end