Class: DownloadTV::Torrentz

Inherits:
LinkGrabber show all
Defined in:
lib/download_tv/grabbers/torrentz.rb

Overview

Torrentz2 grabber

Instance Attribute Summary

Attributes inherited from LinkGrabber

#url

Instance Method Summary collapse

Methods inherited from LinkGrabber

#agent, #online?

Constructor Details

#initializeTorrentz

Returns a new instance of Torrentz.



7
8
9
# File 'lib/download_tv/grabbers/torrentz.rb', line 7

def initialize
  super('https://torrentz2.nz/search?q=%s')
end

Instance Method Details

Raises:



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/download_tv/grabbers/torrentz.rb', line 11

def get_links(show)
  raw_data = agent.get(format(@url, show))
  results = raw_data.search('dl')

  raise NoTorrentsError if results.empty?

  data = results.sort_by { |e| e.search('dd span')[3].text.to_i }.reverse

  data.collect do |i|
    [i.children[0].text.strip,
     i.search('dd span a').first.attribute('href').text]
  end
end