kubrick 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/kubrick.gemspec +23 -0
- data/lib/kubrick.rb +44 -0
- data/lib/kubrick/errors.rb +6 -0
- data/lib/kubrick/version.rb +3 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/kubrick.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "kubrick/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "kubrick"
|
7
|
+
s.version = Kubrick::VERSION
|
8
|
+
s.authors = ["J-P Teti"]
|
9
|
+
s.email = ["roboteti@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = "Netflix Catalog API wrapper"
|
12
|
+
s.description = "A Ruby wrapper for the Netflix Catalog API."
|
13
|
+
|
14
|
+
s.rubyforge_project = "kubrick"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "httparty"
|
22
|
+
s.add_runtime_dependency "ruby_odata"
|
23
|
+
end
|
data/lib/kubrick.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'ruby_odata'
|
2
|
+
require File.expand_path("../kubrick/version", __FILE__)
|
3
|
+
require File.expand_path("../kubrick/errors", __FILE__)
|
4
|
+
|
5
|
+
module Kubrick
|
6
|
+
NETFLIX_API_ROOT = 'http://odata.netflix.com/Catalog'
|
7
|
+
|
8
|
+
class Movie
|
9
|
+
@svc = OData::Service.new NETFLIX_API_ROOT
|
10
|
+
|
11
|
+
def self.find_by_title(title)
|
12
|
+
if title.nil?
|
13
|
+
raise Errors::KubrickError "Movie.find_by_title: title cannot be nil."
|
14
|
+
else
|
15
|
+
@svc.Titles.filter("Name eq '#{title}'")
|
16
|
+
movie = @svc.execute
|
17
|
+
JSON.parse(movie.to_json) # I know, this is horrible, but I couldn't get it to work any other way.
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.find_by_director(name)
|
22
|
+
if name.nil?
|
23
|
+
raise Errors::KubrickError "Movie.find_by_director: name cannot be nil"
|
24
|
+
end
|
25
|
+
@svc.People.filter("Name eq '#{name}'").expand('TitlesDirected')
|
26
|
+
person = @svc.execute
|
27
|
+
parsed = JSON.parse(person.to_json)
|
28
|
+
parsed[0]['TitlesDirected']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Person
|
33
|
+
@svc = OData::Service.new NETFLIX_API_ROOT
|
34
|
+
|
35
|
+
def self.find_by_name(name)
|
36
|
+
if name.nil?
|
37
|
+
raise Errors::KubrickError "Person.find_by_name: name cannot be nil"
|
38
|
+
end
|
39
|
+
@svc.People.filter("Name eq '#{name}'").expand('TitlesDirected')
|
40
|
+
person = @svc.execute
|
41
|
+
JSON.parse(person.to_json)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kubrick
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- J-P Teti
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: &8568450 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *8568450
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ruby_odata
|
27
|
+
requirement: &8567570 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *8567570
|
36
|
+
description: A Ruby wrapper for the Netflix Catalog API.
|
37
|
+
email:
|
38
|
+
- roboteti@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- Rakefile
|
46
|
+
- kubrick.gemspec
|
47
|
+
- lib/kubrick.rb
|
48
|
+
- lib/kubrick/errors.rb
|
49
|
+
- lib/kubrick/version.rb
|
50
|
+
homepage: ''
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project: kubrick
|
70
|
+
rubygems_version: 1.8.15
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Netflix Catalog API wrapper
|
74
|
+
test_files: []
|