Class: BtjunkieContainer::Torrent
- Inherits:
-
Object
- Object
- BtjunkieContainer::Torrent
- Defined in:
- lib/btjunkie/torrent.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
Returns the value of attribute title.
-
#torrent ⇒ Object
Returns the value of attribute torrent.
Instance Method Summary collapse
-
#dead? ⇒ Boolean
Is the torrent dead? The definition of dead is; no seeders Returns a boolean.
- #details ⇒ Object
-
#domain ⇒ Object
Returns the domain for the torrent, without http or www If the domain for some reason isn’t found, it will use an empty string.
-
#id ⇒ Object
(also: #torrent_id)
Generates an id using the details url.
- #imdb_id ⇒ Object
-
#initialize(args) ⇒ Torrent
constructor
A new instance of Torrent.
-
#movie ⇒ Object
Returns an movie_searcher object based on the imdb_id, if it exists, otherwise the torrent title Read more about it here: github.com/oleander/MovieSearcher Return type: A MovieSearcher object or nil.
- #seeders ⇒ Object
-
#subtitle(option = :english) ⇒ Object
Returns a Undertexter object, if we found a imdb_id, otherwise nil Read more about it here: github.com/oleander/Undertexter Return type: A single Undertexter object or nil.
-
#tid ⇒ Object
Returns a unique id for the torrent based on the domain and the id of the torrent.
-
#valid? ⇒ Boolean
The torrent is only valid if it has an id.
Constructor Details
#initialize(args) ⇒ Torrent
Returns a new instance of Torrent.
6 7 8 9 |
# File 'lib/btjunkie/torrent.rb', line 6 def initialize(args) @_subtitle = {} args.keys.each { |name| instance_variable_set "@" + name.to_s, args[name] } end |
Instance Attribute Details
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/btjunkie/torrent.rb', line 5 def title @title end |
#torrent ⇒ Object
Returns the value of attribute torrent.
5 6 7 |
# File 'lib/btjunkie/torrent.rb', line 5 def torrent @torrent end |
Instance Method Details
#dead? ⇒ Boolean
Is the torrent dead? The definition of dead is; no seeders Returns a boolean
14 15 16 |
# File 'lib/btjunkie/torrent.rb', line 14 def dead? seeders <= 0 end |
#details ⇒ Object
59 60 61 |
# File 'lib/btjunkie/torrent.rb', line 59 def details @_details ||= "http://#{domain}#{@details}" end |
#domain ⇒ Object
Returns the domain for the torrent, without http or www If the domain for some reason isn’t found, it will use an empty string
29 30 31 |
# File 'lib/btjunkie/torrent.rb', line 29 def domain "btjunkie.org" end |
#id ⇒ Object Also known as: torrent_id
Generates an id using the details url
23 24 25 |
# File 'lib/btjunkie/torrent.rb', line 23 def id @_id ||= torrent.to_s.match(/(\w+)\/download\.torrent$/).to_a[1] end |
#imdb_id ⇒ Object
70 |
# File 'lib/btjunkie/torrent.rb', line 70 def imdb_id; nil; end |
#movie ⇒ Object
Returns an movie_searcher object based on the imdb_id, if it exists, otherwise the torrent title Read more about it here: github.com/oleander/MovieSearcher Return type: A MovieSearcher object or nil
46 47 48 49 50 |
# File 'lib/btjunkie/torrent.rb', line 46 def movie @_movie ||= MovieSearcher.find_by_release_name(title, :options => { :details => true }) end |
#seeders ⇒ Object
18 19 20 |
# File 'lib/btjunkie/torrent.rb', line 18 def seeders @_seeders ||= @seeders.to_i end |
#subtitle(option = :english) ⇒ Object
Returns a Undertexter object, if we found a imdb_id, otherwise nil Read more about it here: github.com/oleander/Undertexter Return type: A single Undertexter object or nil
55 56 57 |
# File 'lib/btjunkie/torrent.rb', line 55 def subtitle(option = :english) @_subtitle[option] ||= Undertexter.find(movie.imdb_id, :language => option).based_on(title) end |
#tid ⇒ Object
Returns a unique id for the torrent based on the domain and the id of the torrent
34 35 36 |
# File 'lib/btjunkie/torrent.rb', line 34 def tid @_tid ||= Digest::MD5.hexdigest("#{domain}#{id}") end |
#valid? ⇒ Boolean
The torrent is only valid if it has an id
64 65 66 67 68 |
# File 'lib/btjunkie/torrent.rb', line 64 def valid? ! id.nil? and @seeders.match(/^\d+$/) and not @title.to_s.empty? end |