imdb-scan 0.0.1

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.
@@ -0,0 +1,55 @@
1
+ Welcome to Ruby IMDB-SCAN
2
+ --------------------
3
+
4
+ ruby-imdb is IMDB parsing library for Ruby.
5
+ It's an upgrade from this gem: http://github.com/yalcin/ruby-imdb
6
+
7
+ Features
8
+ --------
9
+
10
+ - Object Oriented design
11
+ - Fast access to data
12
+
13
+ Download
14
+ --------
15
+
16
+ - [sudo] gem i imdb-scan
17
+ - https://github.com/oniram88/imdb-scan.git
18
+ - git clone git://github.com/oniram88/imdb-scan.git
19
+
20
+
21
+
22
+ Usage
23
+ -----
24
+ require 'rubygems'
25
+ require 'imdb'
26
+
27
+ s = IMDB::Search.new
28
+ s.movie("fear and loathing in las vegas").each do
29
+ |result|
30
+ movie = IMDB::Movie.new(result.id)
31
+ p movie.title
32
+ movie.cast.each do
33
+ |cast|
34
+ p "#{cast.name} as #{cast.char}"
35
+ end
36
+ p movie.poster
37
+ end
38
+
39
+ movie = IMDB::Movie.new(416320)
40
+ p movie.title => "Match Point"
41
+ p movie.cast.length => 37
42
+ p movie.cast.first.name => "Jonathan Rhys Meyers"
43
+ p movie.cast.first.char => "Chris Wilton"
44
+ p movie.cast.first.person.filmography.length => 82
45
+ p movie.director => "Woody Allen"
46
+ p movie.director_person.filmography.length => 399 (this are all Movies)
47
+
48
+
49
+ Authors
50
+ -------
51
+ - Marino Bonetti (mailto:marinobonetti@gmail.com)
52
+
53
+
54
+ This library is released under the terms of the GNU/GPL.
55
+
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require "jeweler"
5
+ Jeweler::Tasks.new do |s|
6
+ s.name = "ruby-imdb"
7
+ s.summary = "Ruby IMDB Parsing Library"
8
+ s.description = s.summary
9
+ s.email = "yalcin@webliyacelebi.com"
10
+ s.homepage = "http://github.com/yalcin/ruby-imdb"
11
+ s.authors = ["Yalcin Acikyildiz"]
12
+ s.files = FileList["[A-Za-z]*", "{lib,features}/**/*", ".gitignore"]
13
+ s.add_dependency "nokogiri", ">= 1.4.1"
14
+ s.add_dependency "json", ">= 1.4.3"
15
+ s.add_dependency "mongo", ">= 1.0.1"
16
+ s.add_dependency "mongo_mapper", ">= 0.7.5"
17
+ s.add_dependency "chronic", ">= 0.2.3"
18
+ #s.add_dependency "rack", ">= 1.1.0"
19
+ end
20
+ rescue LoadError
21
+ puts "Jeweler not available. Install it with: gem install jeweler"
22
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.7.3
@@ -0,0 +1,38 @@
1
+ Feature: Get movie information
2
+ Scenario: Get movie information and cast list from IMDB
3
+ Given I have movie name called "Fear and Loathing In Las Vegas"
4
+ When I get first entry from result set
5
+ Then "Johnny Depp" should be act as "Raoul Duke"
6
+ And the genres should be "Adventure, Drama"
7
+ And the rating should be a number between 0 and 10
8
+ And the release year should be 1999
9
+ And the poster should be a link to an image
10
+ And the director should be "Terry Gilliam"
11
+ And the director person should be a Class of Person
12
+ And it should have many photos
13
+ And the writers should be "Hunter S. Thompson, Terry Gilliam, Tony Grisoni, Tod Davies, Alex Cox"
14
+ And the short_description should be "An oddball journalist and his psychopathic lawyer travel to Las Vegas for a series of psychadelic escapades."
15
+ And the movielength should be "118"
16
+ Scenario: Partial date: Some movies have not a full date
17
+ Given I have movie name called "Russian Roulette"
18
+ When I get first entry from result set
19
+ Then the release year should be 2010
20
+ Scenario: Some movies have no released date at all, but a year in the title
21
+ Given I have movie name called "Dr. Horrible's Sing-Along Blog"
22
+ When I get first entry from result set
23
+ Then the release year should be 2008
24
+ And the title should be "Dr. Horrible's Sing-Along Blog"
25
+ Scenario: Title of minor movies is different
26
+ Given I have movie name called "Kunpan: Legend of the Warlord"
27
+ When I get first entry from result set
28
+ Then the title should be "Kun pan"
29
+ Scenario: Whant Original Poster
30
+ Given I have movie name called "L'era glaciale 3 - L'alba dei dinosauri"
31
+ When I get first entry from result set
32
+ Then the poster should be a link to an image
33
+ And the poster should be "http://ia.media-imdb.com/images/M/MV5BMjA4NDI0Mjg4NV5BMl5BanBnXkFtZTcwOTM1NTY0Mg@@.jpg"
34
+ Scenario: Whant director name
35
+ Given I have movie with id "1067106"
36
+ Then the director should be "Robert Zemeckis"
37
+ Then the director person should be a Class of Person
38
+
@@ -0,0 +1,11 @@
1
+ Feature: Get Person information
2
+
3
+ Scenario: Get person information and filmography list from IMDB
4
+ Given I have person with id "0000288"
5
+ When the name should be "Christian Bale"
6
+ When the films where he was actor should be "135"
7
+ When the height of the actor should be "1.83 m"
8
+ When the photo should be a link to an image
9
+ When the birth date should be "1974-01-30"
10
+ When the real name shoud be "Christian Charles Philip Bale"
11
+ When the profile path shuld be "/name/nm0000288"
@@ -0,0 +1,12 @@
1
+ Feature: Search IMDB
2
+ Scenario: Search a movie in imdb
3
+ Given I have keyword "District 9" for the search
4
+ Then the result should be equal or greater than 1
5
+ Scenario: For some unique results, imdb redirects directly to movie page, in that cases, there is no search-results page
6
+ Given I have keyword "Wo ist Fred" for the search
7
+ Then the result should be equal to 1
8
+ And the first title should be "Wo ist Fred? (2006)"
9
+ Scenario: Search a film that have many results
10
+ Given I have keyword "Match Point" for the search
11
+ Then The result 0416320 should be unique in the list
12
+
@@ -0,0 +1,94 @@
1
+ begin
2
+ require 'rspec/expectations';
3
+ rescue LoadError;
4
+ require 'spec/expectations';
5
+ end
6
+ require 'cucumber/formatter/unicode'
7
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
8
+ require 'imdb'
9
+
10
+ Before do
11
+ end
12
+
13
+ After do
14
+ end
15
+
16
+ Given /I have movie name called "(.*)"/ do |n|
17
+ @result = IMDB::Search.new.movie(n.to_s)
18
+ end
19
+
20
+ Given /^I have movie with id "(.*)"/ do |n|
21
+ @movie = IMDB::Movie.new(n)
22
+ end
23
+
24
+ When /I get first entry from result set/ do
25
+ @movie = IMDB::Movie.new(@result[0].imdb_id)
26
+ end
27
+
28
+ Then /^"(.*?)" should be act as "(.*?)"$/ do |person, act_as|
29
+ @movie.cast.each do |c|
30
+ if c.name == person and c.char == act_as
31
+ c.name.should == person and c.char.should == act_as
32
+ end
33
+ end
34
+ end
35
+
36
+ Then /^the genres should be "(.*?)"$/ do |arg1|
37
+ @movie.genres.should == arg1.split(/, */)
38
+ end
39
+
40
+ Then /^the rating should be a number between (\d+) and (\d+)$/ do |min, max|
41
+ @movie.rating.should be_kind_of Numeric
42
+ (min.to_f...max.to_f).should include @movie.rating
43
+ end
44
+
45
+ Then /the release year should be (\d+)/ do |year|
46
+ Date.parse(@movie.release_date).year.should == year.to_i
47
+
48
+ end
49
+
50
+ Then /^the poster should be a link to an image$/ do
51
+ @movie.poster.should be_kind_of String
52
+ @movie.poster.should =~ /^http:.*jpg$/
53
+ end
54
+
55
+
56
+ Then /^the director should be "(.*?)"$/ do |arg1|
57
+ @movie.director.should == arg1
58
+ end
59
+
60
+ Then /^the director person should be a Class of Person$/ do
61
+ @movie.director_person.should be_kind_of IMDB::Person
62
+ end
63
+
64
+ Then /^it should have many photos$/ do
65
+ @movie.photos.count.should > 3
66
+ @movie.photos.each do |photo|
67
+ photo.should =~ /^http:.*jpg$/
68
+ end
69
+ end
70
+
71
+ Then /^the writers should be "(.*?)"$/ do |arg1|
72
+ @movie.writers.map { |i| i.name }.join(", ").should == arg1
73
+ end
74
+
75
+ Then /^the short_description should be "(.*?)"$/ do |arg1|
76
+ @movie.short_description.should == arg1
77
+ end
78
+
79
+ Then /^the title should be "(.*)"$/ do |title|
80
+ @movie.title.should == title
81
+ end
82
+
83
+ Then /^the poster should be "(.*)"$/ do |poster|
84
+ @movie.poster.should == poster
85
+ end
86
+
87
+ Then /^the movielength should be "(.*)"$/ do |duration|
88
+ @movie.movielength.should be_kind_of Integer
89
+ @movie.movielength.should == duration.to_i
90
+ end
91
+
92
+
93
+
94
+
@@ -0,0 +1,48 @@
1
+ begin
2
+ require 'rspec/expectations';
3
+ rescue LoadError;
4
+ require 'spec/expectations';
5
+ end
6
+ require 'cucumber/formatter/unicode'
7
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
8
+ require 'imdb'
9
+
10
+ Before do
11
+ end
12
+
13
+ After do
14
+ end
15
+
16
+ Given /I have person with id "(.*)"/ do |n|
17
+ @result = IMDB::Person.new(n.to_s)
18
+ end
19
+
20
+ Then /^the name should be "(.*)"$/ do |name|
21
+ @result.name.should == name
22
+ end
23
+
24
+ Then /^the films where he was actor should be "(.*)"$/ do |number|
25
+ res=@result.filmography
26
+ res.length.should == number.to_i
27
+ end
28
+
29
+ Then /^the height of the actor should be "(.*)"$/ do |height|
30
+ @result.height.should == height.to_s
31
+ end
32
+
33
+ Then /^the photo should be a link to an image$/ do
34
+ @result.photo.should be_kind_of String
35
+ @result.photo.should =~ /^http:.*jpg$/
36
+ end
37
+
38
+ When /^the birth date should be "([^"]*)"$/ do |arg|
39
+ @result.birthdate.should == Date.parse(arg)
40
+ end
41
+
42
+ When /^the profile path shuld be "([^"]*)"$/ do |arg|
43
+ @result.profile_path.should == arg
44
+ end
45
+
46
+ When /^the real name shoud be "([^"]*)"$/ do |arg|
47
+ @result.real_name.should == arg
48
+ end
@@ -0,0 +1,33 @@
1
+ begin
2
+ require 'rspec/expectations';
3
+ rescue LoadError;
4
+ require 'spec/expectations';
5
+ end
6
+ require 'cucumber/formatter/unicode'
7
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
8
+ require 'imdb'
9
+
10
+ Before do
11
+ end
12
+
13
+ After do
14
+ end
15
+
16
+ Given /I have keyword "(.*)" for the search/ do |n|
17
+ @result = IMDB::Search.new.movie(n.to_s)
18
+ end
19
+
20
+ Then /the result should be equal or greater than (\d+)/ do |result|
21
+ @result.length.should >= result.to_i
22
+ end
23
+ Then /the result should be equal to (\d+)/ do |result|
24
+ @result.length.should == result.to_i
25
+ end
26
+ Then /the first title should be "(.*)"/ do |title|
27
+ @result.first.title.should == title
28
+ end
29
+
30
+ Then /The result (\d+) should be unique in the list/ do |id|
31
+ puts @result.inspect
32
+ @result.select { |f| f.imdb_id==id }.length.should == 1
33
+ end
@@ -0,0 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{imdb-scan}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Marino Bonetti","Yalcin Acikyildiz"]
12
+ s.date = %q{2012-09-27}
13
+ s.description = %q{Ruby IMDB Parsing Library}
14
+ s.email = %q{marinobonetti@gmail.com}
15
+ s.extra_rdoc_files = %w(LICENSE README.md)
16
+ s.files = %w(.gitignore LICENSE README.md Rakefile VERSION features/movie.feature features/person.feature features/search.feature features/step_definitions/movie_steps.rb features/step_definitions/person_steps.rb features/step_definitions/search_steps.rb lib/configuration.rb lib/imdb.rb lib/imdb/movie.rb lib/imdb/person.rb lib/imdb/search.rb lib/imdb/skeleton.rb lib/imdb/cast.rb imdb-scan.gemspec)
17
+ s.homepage = %q{http://github.com/yalcin/ruby-imdb}
18
+ s.rdoc_options = %w(--charset=UTF-8)
19
+ s.require_paths = %w(lib)
20
+ s.rubygems_version = %q{1.3.6}
21
+ s.summary = %q{Ruby IMDB Parsing Library}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
29
+ s.add_runtime_dependency(%q<json>, [">= 1.4.3"])
30
+ s.add_runtime_dependency(%q<mongo>, [">= 1.0.1"])
31
+ s.add_runtime_dependency(%q<mongo_mapper>, [">= 0.7.5"])
32
+ s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
33
+ else
34
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
35
+ s.add_dependency(%q<json>, [">= 1.4.3"])
36
+ s.add_dependency(%q<mongo>, [">= 1.0.1"])
37
+ s.add_dependency(%q<mongo_mapper>, [">= 0.7.5"])
38
+ s.add_dependency(%q<chronic>, [">= 0.2.3"])
39
+ end
40
+ else
41
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
42
+ s.add_dependency(%q<json>, [">= 1.4.3"])
43
+ s.add_dependency(%q<mongo>, [">= 1.0.1"])
44
+ s.add_dependency(%q<mongo_mapper>, [">= 0.7.5"])
45
+ s.add_dependency(%q<chronic>, [">= 0.2.3"])
46
+ end
47
+ end
48
+
@@ -0,0 +1,22 @@
1
+ module IMDB
2
+ class Configuration
3
+ class << self
4
+ def caching=(caching)
5
+ @caching = caching
6
+ end
7
+
8
+ def caching
9
+ @caching
10
+ end
11
+
12
+ def db(param={})
13
+ @db_hostname = param[:hostname]
14
+ @db_name = param[:database]
15
+ if @caching
16
+ MongoMapper.connection = Mongo::Connection.new(@db_hostname)
17
+ MongoMapper.database = @db_name
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require "cgi"
2
+ require "open-uri"
3
+
4
+ require "nokogiri"
5
+ require "json"
6
+ require "mongo_mapper"
7
+ require "chronic"
8
+
9
+ class Array
10
+ def to_imdb_hash(default=nil)
11
+ Hash[ *inject([]) { |a, value| a.push value, default || yield(value) } ]
12
+ end
13
+ end
14
+
15
+
16
+ require "configuration"
17
+ require "imdb/skeleton"
18
+ require "imdb/search"
19
+ require "imdb/movie"
20
+ require "imdb/person"
21
+ require "imdb/cast"
22
+
@@ -0,0 +1,38 @@
1
+ module IMDB
2
+ class Cast < IMDB::Skeleton
3
+ attr_accessor :movie, :person, :char
4
+
5
+ def initialize(movie, person, char)
6
+ super("Cast", { :person => Person, :movie => Movie }, [:person, :char])
7
+ @movie = movie
8
+ @person = person
9
+ @char = char
10
+ end
11
+
12
+ def name
13
+ @person.name
14
+ end
15
+
16
+ def char
17
+ @char
18
+ end
19
+
20
+ def imdb_id
21
+ movie.imdb_id
22
+ end
23
+
24
+ def profile
25
+ @person.profile_path
26
+ end
27
+
28
+ def picture
29
+ @person.photo
30
+ end
31
+
32
+ def to_s
33
+ "Name: #{name} \n Char: #{char} \n"
34
+ end
35
+
36
+
37
+ end
38
+ end