Class: Allocine::Show
- Inherits:
-
Object
- Object
- Allocine::Show
- Defined in:
- lib/allocine/show.rb
Instance Attribute Summary collapse
-
#actors ⇒ Object
Returns the value of attribute actors.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#duree ⇒ Object
Returns the value of attribute duree.
-
#genres ⇒ Object
Returns the value of attribute genres.
-
#image ⇒ Object
Returns the value of attribute image.
-
#nat ⇒ Object
Returns the value of attribute nat.
-
#original_title ⇒ Object
Returns the value of attribute original_title.
-
#producters ⇒ Object
Returns the value of attribute producters.
-
#synopsis ⇒ Object
Returns the value of attribute synopsis.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, debug = false) ⇒ Show
constructor
A new instance of Show.
Constructor Details
#initialize(id, debug = false) ⇒ Show
Returns a new instance of Show.
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 |
# File 'lib/allocine/show.rb', line 29 def initialize(id, debug=false) #TODO : New Regex for new version. regexps = { :title => '<title>(.*?)<\/title>', :created_by => '<h4>Série créée par <a .*?>(.*?)</a>', :producters => '<h4>Producteurs : (.*?)</h4>', :nat => '<span style=\'font-weight:bold\'>Nationalité</span> : (.*?)</h5>', :genres => '<span style=\'font-weight:bold\'>Genre</span> : (.*?) ', :duree => '<span style=\'font-weight:bold\'>Format</span> : (.+?). ', :original_title => '<h4><b>Titre original : </b></h4><h4 style="color:#D20000"><b>(.*?)</b></h4>', :actors => '<h4>Avec : (.*?) ', :synopsis => '<h5><span style=\'font-weight:bold\'>Synopsis</span> .*?<br />(.*?)</h5>', :image => '<td><div id=\'divM\' .*?><img src=\'(.*?)\' style=\'border:1px solid black;.*?>', } data = Allocine::Web.new(SHOW_DETAIL_URL % id).data.gsub(/\r|\n|\t/,"") regexps.each do |reg| print "#{reg[0]}: " if debug r = data.scan Regexp.new(reg[1], Regexp::MULTILINE) r = r.first.to_s.strip r.gsub!(' - AlloCiné', '') r.gsub!(/<.*?>/, '') self.instance_variable_set("@#{reg[0]}", r) print "#{r}\n" if debug end end |
Instance Attribute Details
#actors ⇒ Object
Returns the value of attribute actors.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def actors @actors end |
#created_by ⇒ Object
Returns the value of attribute created_by.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def created_by @created_by end |
#duree ⇒ Object
Returns the value of attribute duree.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def duree @duree end |
#genres ⇒ Object
Returns the value of attribute genres.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def genres @genres end |
#image ⇒ Object
Returns the value of attribute image.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def image @image end |
#nat ⇒ Object
Returns the value of attribute nat.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def nat @nat end |
#original_title ⇒ Object
Returns the value of attribute original_title.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def original_title @original_title end |
#producters ⇒ Object
Returns the value of attribute producters.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def producters @producters end |
#synopsis ⇒ Object
Returns the value of attribute synopsis.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def synopsis @synopsis end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/allocine/show.rb', line 3 def title @title end |
Class Method Details
.find(search) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/allocine/show.rb', line 5 def self.find(search) search.gsub!(' ', '+') str = Allocine::Web.new(SHOW_SEARCH_URL % search).data shows = {} while str =~ /<a href='\/series\/ficheserie_gen_cserie=(\d+).html'>(.*?)<\/a>/mi id, name = $1, $2 unless name =~ /<img(.*?)/ str.gsub!("<a href=\'/series/ficheserie_gen_cserie=#{id}.html\'>#{name}</a>", "") name.gsub!(/<(.+?)>/,'') name.strip! shows[id] = name else str.gsub!("<a href=\'/series/ficheserie_gen_cserie=#{id}.html\'>#{name}</a>", "") end end shows end |
.lucky_find(search) ⇒ Object
24 25 26 27 |
# File 'lib/allocine/show.rb', line 24 def self.lucky_find(search) results = find(search) new(results.first) end |