class PopcorntimeSearch::Link
Attributes
filename[W]
imdb_id[RW]
language[RW]
leechers[RW]
magnet[RW]
provider[RW]
quality[RW]
seeders[RW]
size[RW]
title[RW]
Public Class Methods
new(title:, imdb_id:, filename: nil, size: nil, magnet:, seeders:, leechers:, language:, quality:, provider:)
click to toggle source
# File lib/popcorntime_search/link.rb, line 8 def initialize(title:, imdb_id:, filename: nil, size: nil, magnet:, seeders:, leechers:, language:, quality:, provider:) @title = title @imdb_id = imdb_id @filename = filename @size = size @magnet = magnet @seeders = seeders @leechers = leechers @language = language @quality = quality @provider = provider end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/popcorntime_search/link.rb, line 21 def <=>(other) quality <=> other.quality end
filename()
click to toggle source
# File lib/popcorntime_search/link.rb, line 32 def filename @filename ||= parsed_hash['dn'].first end
info_hash()
click to toggle source
# File lib/popcorntime_search/link.rb, line 36 def info_hash @info_hash ||= extract_info_hash end
to_s()
click to toggle source
# File lib/popcorntime_search/link.rb, line 25 def to_s string = "#{title} [#{quality}][#{language.upcase}][#{provider}]" string << " (#{size})" if size string << " - [#{seeders.to_s.green}/#{leechers.to_s.red}]" string end
Private Instance Methods
extract_info_hash()
click to toggle source
# File lib/popcorntime_search/link.rb, line 42 def extract_info_hash # xt=urn:<hash_type>:<info_hash> parsed_hash['xt'].first.split(':').last.downcase end
parsed_hash()
click to toggle source
# File lib/popcorntime_search/link.rb, line 47 def parsed_hash @parsed_hash ||= CGI.parse(magnet.sub('magnet:?', '')) end