public
Description: Your friendly neighborhood nzb downloader
Clone URL: git://github.com/maddox/pyrot.git
Search Repo:
Click here to lend your support to: pyrot and make a donation at www.pledgie.com !
maddox (author)
Fri May 09 11:46:26 -0700 2008
commit  cbc72c7efdfaa5706a17121ed0fda9744def21c0
tree    74a0b2ecacb15b4862ebeac1eb9e677b71cc5293
parent  10e0bd09fa963635be4fea31ead4dc1132c37b72 parent  0a131f384f35df7fb8999da8c65db1b99a04abf9
pyrot / app / controllers / application.rb
100644 58 lines (37 sloc) 1.461 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
 
class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_pyrot_session_id'
 
  before_filter :authenticate
  before_filter :adjust_format_for_iphone
 
 
 
  class Newzbin::Nzb
    attr_accessor :plot, :runtime, :rating, :imdb_id
  end
 
 
  private
 
  def authenticate
    authenticate_or_request_with_http_basic do |user_name, password|
      user_name == PYROT_CONFIG['pyrot']['login'] && password == PYROT_CONFIG['pyrot']['password']
    end
  end
  
  
  # Set iPhone format if request to iphone.pyrot.jtoe.com
  def adjust_format_for_iphone
    request.format = :iphone if iphone_request?
  end
 
  # Return true for requests to iphone.pyrot.jtoe.com
  def iphone_request?
    return (request.subdomains.first == "iphone" || params[:format] == "iphone")
  end
  
  
  
 
  
  # PYROT AND NEWZBIN STUFF
  
  def get_pyrot
    Pyrot.new(:url => 'localhost', :path => '/xmlrpc', :port => '1480')
  end
 
  def get_downloads
    @pyrot = get_pyrot
    @pyrot.downloads
  end
    
  def get_nzb(url)
    newzbin_conn = Newzbin::Connection.new(:username => PYROT_CONFIG['newzbin']['login'], :password => PYROT_CONFIG['newzbin']['password'])
    newzbin_conn.get_nzb(params[:url].match(/\d\d\d+/))
  end
 
 
end