ruby-imdb 0.1.2 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/imdb/movie.rb +36 -8
- data/ruby-imdb.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.2
|
data/lib/imdb/movie.rb
CHANGED
@@ -1,22 +1,50 @@
|
|
1
1
|
module IMDB
|
2
|
-
|
3
|
-
attr_accessor :
|
2
|
+
class Movie
|
3
|
+
attr_accessor :link, :id
|
4
4
|
|
5
5
|
def initialize(id)
|
6
6
|
@id = id
|
7
7
|
@link = "http://www.imdb.com/title/tt#{id}"
|
8
|
-
|
8
|
+
end
|
9
|
+
|
10
|
+
def poster
|
11
|
+
doc.at("a[@name='poster'] img")['src'][/http:.+/] + '.jpg' rescue nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def title
|
15
|
+
doc.at("//head/meta[@name='title']")["content"].split(/\(\d+\)/)[0].strip!
|
16
|
+
end
|
9
17
|
|
10
|
-
|
11
|
-
@poster = doc.at("a[@name='poster'] img")['src'][/http:.+/] + '.jpg' rescue nil
|
12
|
-
@cast = []
|
18
|
+
def cast
|
13
19
|
doc.search("table.cast tr").map do |link|
|
14
20
|
picture = link.children[0].search("img")[0]["src"] rescue nil
|
15
21
|
name = link.children[1].content rescue nil
|
16
22
|
char = link.children[3].content rescue nil
|
17
|
-
|
23
|
+
IMDB::Person.new(name, char, picture, picture) if name and char and picture != nil
|
18
24
|
end
|
19
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
def photos
|
28
|
+
begin
|
29
|
+
doc.search("img").map do |img|
|
30
|
+
unless img["src"][/_CR/].nil?
|
31
|
+
img["src"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def doc
|
42
|
+
if caller[0] =~ /`([^']*)'/ and $1 == "cast"
|
43
|
+
@doc = Nokogiri::HTML(open("#{@link}/fullcredits"))
|
44
|
+
else
|
45
|
+
@doc = Nokogiri::HTML(open("#{@link}"))
|
46
|
+
end
|
47
|
+
|
20
48
|
end
|
21
49
|
end # Movie
|
22
50
|
end # IMDB
|
data/ruby-imdb.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby-imdb}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Yalcin Acikyildiz"]
|
12
|
-
s.date = %q{2010-04
|
12
|
+
s.date = %q{2010-05-04}
|
13
13
|
s.description = %q{Ruby IMDB Parsing Library}
|
14
14
|
s.email = %q{yalcin@webliyacelebi.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 1
|
8
7
|
- 2
|
9
|
-
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Yalcin Acikyildiz
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04
|
17
|
+
date: 2010-05-04 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|