class TTWatcher::Parsers::Unionpeer

Private Instance Methods

extract_torrent(unparsed_data) click to toggle source

@param [Nokogiri::Node] unparsed_data

Surface scan for +unionpeer+ gives next information about single torrent

  ++   hsh[:name]             ==> ex. "Cats swimming in pool 2016 BDRIP"
  --   hsh[:description]      ==> ex. "Hot CATS. Summer 2016"
  ++   hsh[:url]              ==> ex. "example.torrent.side/12345"
  ++   hsh[:tracker]          ==> ex. :super_cool_tracker
  ++   hsh[:author]           ==> ex. 'Bit kitty fun'
  ++   hsh[:added_date]       ==> ex. '2016-06-15'
  ++   hsh[:seeders]          ==> ex. 50042
  ++   hsh[:leeches]          ==> ex. 1
  ++   hsh[:size]             ==> ex. "20000 mb"
  --   hsh[:magnet_url]       ==> ex. "magnet:?xt=urn....................."
  ++   hsh[:download_url]     ==> ex. "example.torrent.side/12345/download"

Where '++' means that field is present.

@return [Torrent]

# File sources/ttwatcher/sites/parsers/unionpeer_parser.rb, line 40
def extract_torrent(unparsed_data)
  hsh = Hash.new

  hsh[:name]       = unparsed_data.css('a[@class="genmed2 tLink"]').text
  hsh[:author]     = unparsed_data.css('td[@class=row1]')[2].text
  hsh[:size]       = unparsed_data.css('a[@class="small tr-dl"]').text
  hsh[:added_date] = unparsed_data.css('td[@class="row4 small nowrap"]').css('p')[1].text
  hsh[:seeders]    = unparsed_data.css('td[@class="row4 seedmed bold"]').text.to_i
  hsh[:leeches]    = unparsed_data.css('td[@class="row4 leechmed"]').text.to_i

  url = unparsed_data.css('a[@class="genmed2 tLink"]').attr('href').to_s
  hsh[:url] = assigned_site.address(url)

  url = unparsed_data.css('a[@class="small tr-dl"]').attr('href').to_s
  hsh[:download_url] = assigned_site.address(url)

  hsh[:tracker] = assigned_site.name

  return Torrent.new(hsh)
end
new_pages_list() click to toggle source
# File sources/ttwatcher/sites/parsers/unionpeer_parser.rb, line 8
def new_pages_list # no-doc
  return @links if @links.is_a? Array

  @links = structure.css('p[@class="small"]').css('a').map do |node|
    node.attr('href')
  end.slice!(1..-2) || []
end
torrents_unparsed() click to toggle source
# File sources/ttwatcher/sites/parsers/unionpeer_parser.rb, line 16
def torrents_unparsed # no-doc
  structure.css 'tr[class="tCenter hl-tr "]'
end