Class: SubtitlesNet

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

Instance Method Summary collapse

Constructor Details

#initializeSubtitlesNet

Returns a new instance of SubtitlesNet.



5
6
7
# File 'lib/subdl/subtitles_net.rb', line 5

def initialize
  @agent = Mechanize.new
end

Instance Method Details

#get(url) ⇒ Object



21
22
23
# File 'lib/subdl/subtitles_net.rb', line 21

def get url
  @agent.get(url).body
end

#search(text, season, episode) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/subdl/subtitles_net.rb', line 8

def search text, season, episode
  @agent.get 'http://www.sub-titles.net/' do |page|
      form = page.form_with( :name => 'sf3') do |search|
        search.sK = text
        search.sTS = season
        search.sTE = episode
        search.field_with(:name=>'sJ').value=2
        # 2 -> Inglese
        # 9 -> Italiano
      end
      return form.submit.body
  end
end