Sha256: a74f820d3d466deb3808adbcedff509e407ee713f832a8abf00a4672f4e686d8

Contents?: true

Size: 756 Bytes

Versions: 13

Compression:

Stored size: 756 Bytes

Contents

# frozen_string_literal: true

module DownloadTV
  ##
  # ThePirateBay grabber
  class ThePirateBay < LinkGrabber
    def initialize(tpb_proxy = 'https://pirateproxy.sh/')
      proxy = tpb_proxy.gsub(%r{/+$}, '')

      super("#{proxy}/search/%s/0/7/0")
    end

    def get_links(show)
      search = format(@url, show)

      # Skip the header
      data = @agent.get(search).search('#searchResult tr').drop 1

      raise NoTorrentsError if data.empty?

      # Second cell of each row contains links and name
      results = data.map { |d| d.search('td')[1] }

      names = results.collect { |i| i.search('.detName').text.strip }
      links = results.collect { |i| i.search('a')[1].attribute('href').text }

      names.zip(links)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
download_tv-2.6.6 lib/download_tv/grabbers/tpb.rb
download_tv-2.6.5 lib/download_tv/grabbers/tpb.rb
download_tv-2.6.4 lib/download_tv/grabbers/tpb.rb
download_tv-2.6.3 lib/download_tv/grabbers/tpb.rb
download_tv-2.6.2 lib/download_tv/grabbers/tpb.rb
download_tv-2.6.1 lib/download_tv/grabbers/tpb.rb
download_tv-2.6.0 lib/download_tv/grabbers/tpb.rb
download_tv-2.5.5 lib/download_tv/grabbers/tpb.rb
download_tv-2.5.4 lib/download_tv/grabbers/tpb.rb
download_tv-2.5.3 lib/download_tv/grabbers/tpb.rb
download_tv-2.5.2 lib/download_tv/grabbers/tpb.rb
download_tv-2.5.1 lib/download_tv/grabbers/tpb.rb
download_tv-2.5.0 lib/download_tv/grabbers/tpb.rb