Class: DownloadTV::Addic7ed

Inherits:
LinkGrabber show all
Defined in:
lib/download_tv/grabbers/addic7ed.rb

Overview

Addic7ed prototype (WIP)

Instance Attribute Summary

Attributes inherited from LinkGrabber

#url

Instance Method Summary collapse

Methods inherited from LinkGrabber

#get_links, #online?

Constructor Details

#initializeAddic7ed

Returns a new instance of Addic7ed.



7
8
9
10
# File 'lib/download_tv/grabbers/addic7ed.rb', line 7

def initialize
  super('http://www.addic7ed.com/search.php?search=%s'\
        '&Submit=Search')
end

Instance Method Details

#download_file(url) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/download_tv/grabbers/addic7ed.rb', line 41

def download_file(url)
  # Url must be like 'http://www.addic7ed.com/updated/1/115337/0'

  # ADDIC7ED PROVIDES RSS

  agent = Mechanize.new
  page = agent.get(url, [], @url)
  puts page.save('Hi')
end

#get_subs(show) ⇒ Object



12
13
14
15
# File 'lib/download_tv/grabbers/addic7ed.rb', line 12

def get_subs(show)
  url = get_url(show)
  download_file(url)
end

#get_url(show) ⇒ Object

Raises:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/download_tv/grabbers/addic7ed.rb', line 17

def get_url(show)
  # Change spaces for the separator
  s = show.gsub(' ', @sep)

  # Format the url
  search = Format(@url, s)

  agent = Mechanize.new
  res = agent.get(search)

  # No redirection means no subtitle found
  raise NoSubtitlesError if res.uri.to_s == search

  ##########
  # DO OPENSUBTITLES FIRST (see subtitles.rb)
  #####

  # We now have an URL like:
  # http://www.addic7ed.com/serie/Mr._Robot/2/3/eps2.1k3rnel-pan1c.ksd

  # To find the real links:
  # see comments at the end of file
end