Sha256: e2afcbdf48547e79a25a597fa7a2b83deaee7c3659959c99c95b5c9c9fd9e342
Contents?: true
Size: 898 Bytes
Versions: 1
Compression:
Stored size: 898 Bytes
Contents
require 'cgi' require 'httparty' module TpbSearch ## # Object that contains the info for a torrent file class Link attr_reader :filename, :size, :magnet, :seeders, :leechers def initialize(filename: nil, size: nil, magnet: nil, seeders: nil, leechers: nil) @filename = filename @size = size @magnet = magnet @seeders = seeders.tr(',', '').to_i @leechers = leechers.tr(',', '').to_i end def <=>(other) @seeders <=> other.seeders end def to_s "#{@filename} (#{@size}) - [#{@seeders.to_s.green}/#{@leechers.to_s.red}]" end def info_hash @info_hash ||= extract_hash end private def extract_hash # Extract magnet properties to a Hash and then parse the sha1 info hash raw_hash = magnet[/(xt.*?)&/, 1] # extract the xt property raw_hash.split(':').last.downcase end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tpb_search-0.1.0 | lib/tpb_search/link.rb |