Module: Traktr::Movie
- Includes:
- HTTParty
- Defined in:
- lib/traktr/movie.rb
Class Method Summary collapse
-
.comments(title, type = :all) ⇒ Object
movie GET methods.
-
.library(movies) ⇒ Object
movie POST methods.
- .related(title, hidewatched = false) ⇒ Object
- .seen(movies) ⇒ Object
- .summaries(titles, extended = :min) ⇒ Object
- .summary(title, extended = :min) ⇒ Object
- .unlibrary(movies) ⇒ Object
- .unseen(movies) ⇒ Object
- .unwatchlist(movies) ⇒ Object
- .watchingnow(title) ⇒ Object
- .watchlist(movies) ⇒ Object
Class Method Details
.comments(title, type = :all) ⇒ Object
movie GET methods
9 10 11 12 13 14 15 16 |
# File 'lib/traktr/movie.rb', line 9 def self.comments(title, type = :all) response = self.get('/' + File.join('comments.json', Traktr.api_key, title, type.to_s)) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |comment| Mash.new(comment) end end |
.library(movies) ⇒ Object
movie POST methods
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/traktr/movie.rb', line 56 def self.library(movies) movies = [ movies ] if movies.class != Array data = { username: Traktr.username, password: Traktr.password, movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }} } response = self.post('/' + File.join('library', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'}) raise ResponseError.new(response) if response.code != 200 Mash.new(JSON.parse(response.parsed_response)) end |
.related(title, hidewatched = false) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/traktr/movie.rb', line 18 def self.(title, hidewatched = false) response = self.get('/' + File.join('related.json', Traktr.api_key, title, hidewatched.to_s)) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |summary| Mash.new(summary) end end |
.seen(movies) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/traktr/movie.rb', line 104 def self.seen(movies) movies = [ movies ] if movies.class != Array data = { username: Traktr.username, password: Traktr.password, movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }} } response = self.post('/' + File.join('seen', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'}) raise ResponseError.new(response) if response.code != 200 Mash.new(JSON.parse(response.parsed_response)) end |
.summaries(titles, extended = :min) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/traktr/movie.rb', line 34 def self.summaries(titles, extended = :min) titles = [titles] if titles.class == String response = self.get('/' + File.join('summaries.json', Traktr.api_key, titles.join(','), extended.to_s)) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |summary| Mash.new(summary) end end |
.summary(title, extended = :min) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/traktr/movie.rb', line 27 def self.summary(title, extended = :min) response = self.get('/' + File.join('summary.json', Traktr.api_key, title.to_s, extended.to_s)) raise ResponseError.new(response) if response.code != 200 Mash.new(response.parsed_response) end |
.unlibrary(movies) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/traktr/movie.rb', line 68 def self.unlibrary(movies) movies = [ movies ] if movies.class != Array data = { username: Traktr.username, password: Traktr.password, movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }} } response = self.post('/' + File.join('unlibrary', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'}) raise ResponseError.new(response) if response.code != 200 Mash.new(response.parsed_response) end |
.unseen(movies) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/traktr/movie.rb', line 116 def self.unseen(movies) movies = [ movies ] if movies.class != Array data = { username: Traktr.username, password: Traktr.password, movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }} } response = self.post('/' + File.join('unseen', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'}) raise ResponseError.new(response) if response.code != 200 Mash.new(response.parsed_response) end |
.unwatchlist(movies) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/traktr/movie.rb', line 92 def self.unwatchlist(movies) movies = [ movies ] if movies.class != Array data = { username: Traktr.username, password: Traktr.password, movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }} } response = self.post('/' + File.join('unwatchlist', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'}) raise ResponseError.new(response) if response.code != 200 Mash.new(response.parsed_response) end |
.watchingnow(title) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/traktr/movie.rb', line 44 def self.watchingnow(title) response = self.get('/' + File.join('watchingnow.json', Traktr.api_key, title)) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |user| Mash.new(user) end end |
.watchlist(movies) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/traktr/movie.rb', line 80 def self.watchlist(movies) movies = [ movies ] if movies.class != Array data = { username: Traktr.username, password: Traktr.password, movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }} } response = self.post('/' + File.join('watchlist', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'}) raise ResponseError.new(response) if response.code != 200 Mash.new(JSON.parse(response.parsed_response)) end |