class TTWatcher::Parsers::Megashara
Private Instance Methods
extract_torrent(unparsed_data)
click to toggle source
@param [Nokogiri::Node] unparsed_data
Surface scan for +megashara+ 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/megashara_parser.rb, line 48 def extract_torrent(unparsed_data) hsh = Hash.new hsh[:name] = unparsed_data.css('td')[1].text hsh[:magnet_url] = unparsed_data.css('td').css('a')[1].attr('href').to_s hsh[:url] = unparsed_data.css('td').css('a').attr('href').to_s hsh[:size] = unparsed_data.css('td')[3].text hsh[:seeders] = unparsed_data.css('td')[4].text.to_i hsh[:leeches] = unparsed_data.css('td')[5].text.to_i hsh[:tracker] = assigned_site.name Torrent.new hsh end
new_pages_list()
click to toggle source
# File sources/ttwatcher/sites/parsers/megashara_parser.rb, line 8 def new_pages_list # no-doc return @links if @links.is_a? Array unparsed_html_data = structure.css('table[@class="pagination-table"]') .xpath('tr') .xpath('td')[-2] return @links = [] if unparsed_html_data.nil? pages_count = unparsed_html_data.css('a').text.to_i - 1 link_template = unparsed_html_data.css('a').attr('href').to_s @links = (1..pages_count).map do |i| link_template.gsub /(\d+)$/, i.to_s end end
torrents_unparsed()
click to toggle source
# File sources/ttwatcher/sites/parsers/megashara_parser.rb, line 24 def torrents_unparsed # no-doc structure.css('table[@class="table-wide"]').css('table').css('tr') end