Class: Btjunkie

Inherits:
Object
  • Object
show all
Defined in:
lib/btjunkie.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBtjunkie

Returns a new instance of Btjunkie.



9
10
11
12
13
14
# File 'lib/btjunkie.rb', line 9

def initialize
  @page = 1
  @categories = {
    :movies => "http://btjunkie.org/browse/Video?o=72&t=1&s=1&p=<PAGE>"
  }
end

Class Method Details

.method_missing(meth, *args, &blk) ⇒ Object



32
33
34
# File 'lib/btjunkie.rb', line 32

def self.method_missing(meth, *args, &blk)
  Btjunkie.new.send(meth, *args, &blk)
end

Instance Method Details

#category(what) ⇒ Object



24
25
26
# File 'lib/btjunkie.rb', line 24

def category(what)
  tap { @url = @categories[what] }
end

#cookies(cookies) ⇒ Object



20
21
22
# File 'lib/btjunkie.rb', line 20

def cookies(cookies)
  tap { @cookies = cookies }
end

#find_by_details(url) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/btjunkie.rb', line 36

def find_by_details(url)
  doc = content(url)
  
  if title = doc.at_css(".Wht font")
    title = title.content.strip
  else
    title = ""
  end
  
  BtjunkieContainer::Torrent.new({
    :torrent => doc.to_s.match(/(http.+?\.torrent)/i).to_a[1],
    :details => url.to_s.gsub("http://btjunkie.org", ""),
    :title   => title,
    :seeders => doc.at_css("#main").to_s.match(/([^>][\d,]+) seeds/).to_a[1].to_s.gsub(/[^\d]+/, "")
  })
end

#page(page) ⇒ Object



16
17
18
# File 'lib/btjunkie.rb', line 16

def page(page)
  tap { @page = page }
end

#resultsObject



28
29
30
# File 'lib/btjunkie.rb', line 28

def results
  @_torrents ||= scrape
end