imdb_party 0.5.0 → 0.6.0

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 CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -1,49 +1,47 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{imdb_party}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jon Maddox"]
12
- s.date = %q{2011-04-26}
12
+ s.date = %q{2011-05-02}
13
13
  s.description = %q{IMDB client using the IMDB API that their iPhone app uses}
14
14
  s.email = %q{jon@mustacheinc.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.md"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.md",
24
- "Rakefile",
25
- "VERSION",
26
- "imdb_party.gemspec",
27
- "lib/imdb_party.rb",
28
- "lib/imdb_party/httparty_icebox.rb",
29
- "lib/imdb_party/imdb.rb",
30
- "lib/imdb_party/movie.rb",
31
- "lib/imdb_party/person.rb",
32
- "test/movie_test.rb",
33
- "test/person_test.rb",
34
- "test/search_test.rb",
35
- "test/test_helper.rb"
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "imdb_party.gemspec",
26
+ "lib/imdb_party.rb",
27
+ "lib/imdb_party/httparty_icebox.rb",
28
+ "lib/imdb_party/imdb.rb",
29
+ "lib/imdb_party/movie.rb",
30
+ "lib/imdb_party/person.rb",
31
+ "test/movie_test.rb",
32
+ "test/person_test.rb",
33
+ "test/search_test.rb",
34
+ "test/test_helper.rb"
36
35
  ]
37
36
  s.homepage = %q{http://github.com/maddox/imdb_party}
38
- s.rdoc_options = ["--charset=UTF-8"]
39
37
  s.require_paths = ["lib"]
40
38
  s.rubygems_version = %q{1.4.2}
41
39
  s.summary = %q{IMDB client using the IMDB API that their iPhone app uses}
42
40
  s.test_files = [
43
41
  "test/movie_test.rb",
44
- "test/person_test.rb",
45
- "test/search_test.rb",
46
- "test/test_helper.rb"
42
+ "test/person_test.rb",
43
+ "test/search_test.rb",
44
+ "test/test_helper.rb"
47
45
  ]
48
46
 
49
47
  if s.respond_to? :specification_version then
@@ -61,3 +59,4 @@ Gem::Specification.new do |s|
61
59
  s.add_dependency(%q<httparty>, [">= 0"])
62
60
  end
63
61
  end
62
+
@@ -5,21 +5,39 @@ module ImdbParty
5
5
  cache :store => 'file', :timeout => 120, :location => Dir.tmpdir
6
6
 
7
7
  base_uri 'app.imdb.com'
8
- default_params = {"api" => "v1", "appid" => "iphone1_1", "apiPolicy" => "app1_1", "apiKey" => "2wex6aeu6a8q9e49k7sfvufd6rhh0n", "locale" => "en_US", "timestamp" => Time.now.to_i, "sig" => "heres my signature"}
9
8
 
10
9
  def initialize(options={})
11
- self.class.base_uri 'http://anonymouse.org/cgi-bin/anon-www.cgi/http://app.imdb.com' if options[:anonymize]
10
+ self.class.base_uri 'anonymouse.org/cgi-bin/anon-www.cgi/http://app.imdb.com' if options[:anonymize]
11
+ end
12
+
13
+ def build_url(path, params={})
14
+ default_params = {"api" => "v1", "appid" => "iphone1_1", "apiPolicy" => "app1_1", "apiKey" => "2wex6aeu6a8q9e49k7sfvufd6rhh0n", "locale" => "en_US", "timestamp" => Time.now.to_i}
15
+
16
+ query_params = default_params.merge(params)
17
+ query_param_array = []
18
+
19
+ host = self.class.base_uri.gsub('http://', '').to_s
20
+
21
+ query_params.each_pair{|key, value| query_param_array << "#{key}=#{URI.escape(value.to_s)}" }
22
+ uri = URI::HTTP.build(:scheme => 'https', :host => host, :path => path, :query => query_param_array.join("&"))
23
+
24
+ query_param_array << "sig=app1-#{OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha1'), default_params["apiKey"], uri.to_s)}"
25
+
26
+ uri = URI::HTTP.build(:scheme => 'https', :host => host, :path => path, :query => query_param_array.join("&"))
27
+ uri.to_s
12
28
  end
13
29
 
14
30
  def find_by_title(title)
15
31
  movie_results = []
16
- results = self.class.get('/find', :query => {:q => title}).parsed_response
32
+ url = build_url('/find', :q => title)
33
+
34
+ results = self.class.get(url).parsed_response
17
35
 
18
36
  if results["data"] && results["data"]["results"]
19
37
  results["data"]["results"].each do |result_section|
20
38
  result_section["list"].each do |r|
21
39
  next unless r["tconst"] && r["title"]
22
- h = {:title => r["title"], :year => r["year"], :imdb_id => r["tconst"]}
40
+ h = {:title => r["title"], :year => r["year"], :imdb_id => r["tconst"], :kind => r["type"]}
23
41
  h.merge!(:poster_url => r["image"]["url"]) if r["image"] && r["image"]["url"]
24
42
  movie_results << h
25
43
  end
@@ -30,17 +48,23 @@ module ImdbParty
30
48
  end
31
49
 
32
50
  def find_movie_by_id(imdb_id)
33
- result = self.class.get('/title/maindetails', :query => {:tconst => imdb_id}).parsed_response
51
+ url = build_url('/title/maindetails', :tconst => imdb_id)
52
+
53
+ result = self.class.get(url).parsed_response
34
54
  Movie.new(result["data"])
35
55
  end
36
56
 
37
57
  def top_250
38
- results = self.class.get('/chart/top').parsed_response
58
+ url = build_url('/chart/top')
59
+
60
+ results = self.class.get(url).parsed_response
39
61
  results["data"]["list"]["list"].map { |r| {:title => r["title"], :imdb_id => r["tconst"], :year => r["year"], :poster_url => (r["image"] ? r["image"]["url"] : nil)} }
40
62
  end
41
63
 
42
64
  def popular_shows
43
- results = self.class.get('/chart/tv').parsed_response
65
+ url = build_url('/chart/tv')
66
+
67
+ results = self.class.get(url).parsed_response
44
68
  results["data"]["list"].map { |r| {:title => r["title"], :imdb_id => r["tconst"], :year => r["year"], :poster_url => (r["image"] ? r["image"]["url"] : nil)} }
45
69
  end
46
70
 
@@ -45,7 +45,7 @@ class MovieTest < Test::Unit::TestCase
45
45
 
46
46
  should "have trailers" do
47
47
  assert_equal Hash, @movie.trailers.class
48
- assert_equal 4, @movie.trailers.keys.size
48
+ assert_equal 2, @movie.trailers.keys.size
49
49
  assert_equal "http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e27826&bitrateid=461&vendorid=102&type=.mp4", @movie.trailers[@movie.trailers.keys.first]
50
50
  end
51
51
 
@@ -9,11 +9,11 @@ class PersonTest < Test::Unit::TestCase
9
9
 
10
10
  context "actors" do
11
11
  should "have a name" do
12
- assert_equal "Patton Oswalt", @movie.actors.first.name
12
+ assert_equal "Brad Garrett", @movie.actors.first.name
13
13
  end
14
14
 
15
15
  should "have a role" do
16
- assert_equal "Remy", @movie.actors.first.role
16
+ assert_equal "Gusteau", @movie.actors.first.role
17
17
  end
18
18
  end
19
19
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imdb_party
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 0.5.0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jon Maddox
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-26 00:00:00 -04:00
18
+ date: 2011-05-02 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -57,7 +57,6 @@ extra_rdoc_files:
57
57
  - README.md
58
58
  files:
59
59
  - .document
60
- - .gitignore
61
60
  - LICENSE
62
61
  - README.md
63
62
  - Rakefile
@@ -77,8 +76,8 @@ homepage: http://github.com/maddox/imdb_party
77
76
  licenses: []
78
77
 
79
78
  post_install_message:
80
- rdoc_options:
81
- - --charset=UTF-8
79
+ rdoc_options: []
80
+
82
81
  require_paths:
83
82
  - lib
84
83
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg