movie_searcher 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -4
- data/README.md +88 -13
- data/lib/{movie_searcher/movie_searcher.rb → movie_searcher.rb} +10 -4
- data/movie_searcher.gemspec +2 -2
- data/spec/movie_searcher_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -1
- metadata +7 -7
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,101 @@
|
|
1
|
-
#
|
1
|
+
# MovieSearcher - *the almighty movie search gem*
|
2
2
|
|
3
|
-
##
|
3
|
+
## What is MovieSearcher
|
4
4
|
|
5
|
-
|
5
|
+
MovieSearcher makes it possible to get information about a movie.
|
6
|
+
It uses IMDB's API that their iPhone applications rely on.
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
It's build on top of [maddox's](https://github.com/maddox) [imdb-party](https://github.com/maddox/imdb-party) but adds some extra functionality and bugs fixes.
|
9
|
+
|
10
|
+
## What makes this gem so awesome?
|
11
|
+
MovieSearcher has a really cool feature (*method*) called `find_by_release_name` that makes it possible to search for a movie based on the release name.
|
12
|
+
You can for example specify ***Heartbreaker 2010 LIMITED DVDRip XviD-SUBMERGE*** and it will return the not to good [*Heartbreaker*](http://www.imdb.com/title/tt1465487/) by [*Pascal Chaumeil*](http://www.imdb.com/name/nm0154312/)
|
13
|
+
|
14
|
+
## So how do I use it?
|
9
15
|
|
10
|
-
|
16
|
+
### Start by installing the gem
|
17
|
+
|
18
|
+
sudo gem install movie_searcher
|
19
|
+
Start `irb` and include the gem, `require 'movie_searcher'`
|
20
|
+
|
21
|
+
### Search for a movie by title
|
11
22
|
|
12
|
-
|
23
|
+
$ MovieSearcher.find_by_title("The Dark Knight")
|
24
|
+
=> [#<ImdbParty::Movie:0x1012a5858 @imdb_id="tt0468569", @year="2008", @title="The Dark Knight" ... >, ...]
|
13
25
|
|
14
|
-
|
26
|
+
### Get a movie by its imdb id
|
15
27
|
|
16
|
-
movie
|
17
|
-
movie.
|
18
|
-
|
28
|
+
$ movie = MovieSearcher.find_movie_by_id("tt0468569")
|
29
|
+
$ movie.title
|
30
|
+
=> "The Dark Knight"
|
31
|
+
$ movie.rating
|
32
|
+
=> 8.9
|
33
|
+
$ movie.certification
|
34
|
+
=> "PG-13"
|
19
35
|
|
20
36
|
### Find the top 250 movies of all time
|
21
37
|
|
22
|
-
|
38
|
+
$ MovieSearcher.top_250
|
39
|
+
=> [#<ImdbParty::Movie:0x10178ef68 @imdb_id="tt0111161", @poster_url="http://ia.media-imdb.com/images/M/MV5BMTM2NjEyNzk2OF5BMl5BanBnXkFtZTcwNjcxNjUyMQ@@._V1_.jpg" ... >, ...]
|
23
40
|
|
24
41
|
### Get the currently popular tv shows
|
25
42
|
|
26
|
-
|
43
|
+
$ MovieSearcher.popular_shows
|
44
|
+
=> [#<ImdbParty::Movie:0x101ff2858 @imdb_id="tt1327801", @poster_url="http://ia.media-imdb.com/images/M/MV5BMTYxMjYxNjQxNl5BMl5BanBnXkFtZTcwNTU5Nzk4Mw@@._V1_.jpg", @year="2009", @title="Glee">, ... ]
|
45
|
+
|
46
|
+
### Search for a release name
|
47
|
+
|
48
|
+
$ MovieSearcher.find_by_release_name("Heartbreaker 2010 LIMITED DVDRip XviD-SUBMERGE").imdb_id
|
49
|
+
=> tt1465487
|
50
|
+
|
51
|
+
### Some configure alternatives
|
52
|
+
You can pass some options to the `find_by_release_name` method to specify how it should behave.
|
53
|
+
|
54
|
+
Here is an example.
|
55
|
+
|
56
|
+
$ MovieSearcher.find_by_release_name("Heartbreaker 2010 LIMITED DVDRip XviD-SUBMERGE", :options => {:limit => 0.1, :details => true})
|
57
|
+
|
58
|
+
- ** :limit ** (Float) It defines how sensitive the parsing algorithm should be. Where 0.0 is super sensitive and 1.0 is don't care. The default value is 0.4 and workes in most cases. If you dont get any hits at all, try a large value.
|
59
|
+
- ** :details ** (Boolean) By default, the `find_by_release_name` only returns the most basic information about a movie, like *imdb_id*, *title* and *year*. If you set this to true, it will do another request to IMDB and get the casts, actors, rating and so on.
|
60
|
+
|
61
|
+
** The option param can't be passed to `find_by_title` **
|
62
|
+
|
63
|
+
** `find_movie_by_id` don't require that you pass the `:details` option to get all data **
|
64
|
+
|
65
|
+
## What is being returned?
|
66
|
+
|
67
|
+
The `find_by_title` method returns an `Array` of `ImdbParty::Movie` objects.
|
68
|
+
|
69
|
+
These are the accessors of `ImdbParty::Movie`
|
70
|
+
|
71
|
+
- **imdb_id** (String) The imdb id of the movie.
|
72
|
+
- **title** (String) The title of the movie.
|
73
|
+
- **directors** (Array) Related directors.
|
74
|
+
- **writers** (Array) Related writers.
|
75
|
+
- **tagline** (String) The movie tagline.
|
76
|
+
- **company** (String) Company who made the movie.
|
77
|
+
- **runtime** (String) The length of the movie, `120 min` for example.
|
78
|
+
- **rating** (Float) The movie rating, from 0 to 10.
|
79
|
+
- **poster_url** (String) Movie poster. **Beaware**, this image might expire. Use [tmdb_party](https://github.com/jduff/tmdb_party) if you want posters and images.
|
80
|
+
- **release_date** (Date) The release date of the movie.
|
81
|
+
- **certification** (String) The certification of the movie, *R* for example.
|
82
|
+
- **genres** (Array) The most relevant generes for the movie.
|
83
|
+
- **actors** (Array) Related actors.
|
84
|
+
- **trailers** (Hash) Related trailers. The key defines the quality of the trailer, like `H.264 480x360` and the value specify the url.
|
85
|
+
|
86
|
+
The `actors`, `writers` and `directors` accessors returns an `ImdbParty::Person` object that has the following accessors.
|
87
|
+
|
88
|
+
- **imdb_id** (String) The imdb id of the person.
|
89
|
+
- **role** (String) What role did the actor have in the movie. This is only set when working with an actor.
|
90
|
+
- **name** (String) The actual name of the actor.
|
91
|
+
|
92
|
+
## This sounds supr, how do I help?
|
93
|
+
|
94
|
+
- Start by copying the project or make your own branch.
|
95
|
+
- Navigate to the root path of the project and run `bundle`.
|
96
|
+
- Start by running all tests using rspec, `rspec spec/movie_searcher_spec.rb`.
|
97
|
+
- Implement your own code, write some tests, commit and do a pull request.
|
98
|
+
|
99
|
+
## Requirements
|
100
|
+
|
101
|
+
The gem is tested in OS X 10.6.6 using Ruby 1.8.7.
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require "
|
1
|
+
require "imdb_party"
|
2
2
|
require 'levenshtein'
|
3
3
|
|
4
4
|
class MovieSearcher
|
5
|
+
attr_accessor :options
|
6
|
+
|
5
7
|
def initialize(args)
|
6
8
|
args.keys.each { |name| instance_variable_set "@" + name.to_s, args[name] unless name == :options }
|
7
9
|
|
@@ -19,7 +21,11 @@ class MovieSearcher
|
|
19
21
|
this = MovieSearcher.new(options.merge(:search_value => search_value.to_s))
|
20
22
|
return if this.to_long?
|
21
23
|
|
22
|
-
|
24
|
+
movie = this.find_the_movie!
|
25
|
+
return if movie.nil?
|
26
|
+
|
27
|
+
# If the user wants for information about the movie, the {options[:details]} option should be true
|
28
|
+
this.options[:details] ? self.find_movie_by_id(movie.imdb_id) : movie
|
23
29
|
end
|
24
30
|
|
25
31
|
def to_long?
|
@@ -55,8 +61,8 @@ class MovieSearcher
|
|
55
61
|
return ImdbParty::Movie.new(movie.first)
|
56
62
|
end
|
57
63
|
|
58
|
-
def self.method_missing(
|
59
|
-
result = ImdbParty::Imdb.new.send(
|
64
|
+
def self.method_missing(method, *args, &block)
|
65
|
+
result = ImdbParty::Imdb.new.send(method, *args)
|
60
66
|
return if result.nil?
|
61
67
|
result.class == Array ? result.map{|r| ImdbParty::Movie.new(r)} : result
|
62
68
|
end
|
data/movie_searcher.gemspec
CHANGED
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "movie_searcher"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.4"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Linus Oleander", "Jon Maddox"]
|
9
9
|
s.email = ["linus@oleander.nu", "jon@mustacheinc.com"]
|
10
|
-
s.homepage = "
|
10
|
+
s.homepage = "http://github.com/oleander/MovieSearcher"
|
11
11
|
s.summary = %q{IMDB client using the IMDB API that their iPhone app uses}
|
12
12
|
s.description = %q{IMDB client using the IMDB API that their iPhone app uses. It can also figure out what movie you are looking for just by looking at the release name of the movie}
|
13
13
|
|
data/spec/movie_searcher_spec.rb
CHANGED
@@ -42,6 +42,14 @@ describe MovieSearcher do
|
|
42
42
|
it "should return nil if nil is being passed to it" do
|
43
43
|
MovieSearcher.find_by_release_name(nil).should be_nil
|
44
44
|
end
|
45
|
+
|
46
|
+
it "should not have a rating if the details option isn't being passed" do
|
47
|
+
MovieSearcher.find_by_release_name('Paranormal Activity 2 2010 UNRATED DVDRip XviD-Larceny').rating.should be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return a rating if the detail option is being passed" do
|
51
|
+
MovieSearcher.find_by_release_name('Paranormal Activity 2 2010 UNRATED DVDRip XviD-Larceny', :options => {:details => true}).rating.should_not be_nil
|
52
|
+
end
|
45
53
|
end
|
46
54
|
|
47
55
|
describe MovieSearcher, "should work as before" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: movie_searcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Linus Oleander
|
@@ -86,12 +86,12 @@ files:
|
|
86
86
|
- lib/imdb_party/imdb.rb
|
87
87
|
- lib/imdb_party/movie.rb
|
88
88
|
- lib/imdb_party/person.rb
|
89
|
-
- lib/movie_searcher
|
89
|
+
- lib/movie_searcher.rb
|
90
90
|
- movie_searcher.gemspec
|
91
91
|
- spec/movie_searcher_spec.rb
|
92
92
|
- spec/spec_helper.rb
|
93
93
|
has_rdoc: true
|
94
|
-
homepage:
|
94
|
+
homepage: http://github.com/oleander/MovieSearcher
|
95
95
|
licenses: []
|
96
96
|
|
97
97
|
post_install_message:
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
requirements: []
|
121
121
|
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 1.
|
123
|
+
rubygems_version: 1.4.2
|
124
124
|
signing_key:
|
125
125
|
specification_version: 3
|
126
126
|
summary: IMDB client using the IMDB API that their iPhone app uses
|