Sha256: b55e8e1f115cff52d83ab3f5c6d62f6eab0e96c421b6d420e8a191955805d922

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

module DownloadTV
  ##
  # KATcr.co grabber
  class KAT < LinkGrabber
    def initialize
      super('https://katcr.co/advanced-usearch/')
    end

    def get_links(s)
      tries = 0
      max_tries = 5

      params = {
        'category': 'TV',
        'orderby': 'seeds-desc',
        'search': s
      }

      data = @agent.post(@url, params).search('tbody tr td[1]')

      names = data.map { |i| i.search('a.torrents_table__torrent_title b').text }
      links = data.map { |i| i.search('div.torrents_table__actions a[3]').first.attribute('href').text }

      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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
download_tv-2.4.7 lib/download_tv/grabbers/kat.rb