Class: DownloadTV::Eztv

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

Overview

EZTV.ag grabber

Instance Attribute Summary

Attributes inherited from LinkGrabber

#url

Instance Method Summary collapse

Methods inherited from LinkGrabber

#online?

Constructor Details

#initializeEztv

Returns a new instance of Eztv.



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

def initialize
  super('https://eztv.ag/search/%s')
end

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/download_tv/grabbers/eztv.rb', line 11

def get_links(show)
  # Format the url
  search = format(@url, show)

  raw_data = @agent.get(search)
  raw_links = raw_data.search('a.magnet')
  raw_seeders = raw_data.search('td.forum_thread_post_end').map { |e| e.children[0].text.to_i }
  raw_links = raw_links.sort_by.with_index { |_, index| raw_seeders[index] }.reverse

  # Torrent name in raw_links[i].attribute 'title'
  # 'Suits S04E01 HDTV x264-LOL Torrent: Magnet Link'

  # EZTV shows 50 latest releases if it can't find the torrent
  raise NoTorrentsError if raw_links.size == 50

  names = raw_links.collect do |i|
    i.attribute('title')
     .text
     .chomp(' Magnet Link')
  end
  links = raw_links.collect do |i|
    i.attribute('href')
     .text
  end

  names.zip(links)
end