Module: Traktr::Show::Episode
- Includes:
- HTTParty
- Defined in:
- lib/traktr/show/episode.rb
Class Method Summary collapse
-
.comments(title, season, episode) ⇒ Object
show-episode GET methods.
-
.library(show, episodes) ⇒ Object
show-episode POST methods.
- .seen(show, episodes) ⇒ Object
- .summary(title, season, episode) ⇒ Object
- .unlibrary(show, episodes) ⇒ Object
- .unseen(show, episodes) ⇒ Object
- .unwatchlist(show, episodes) ⇒ Object
- .watchingnow(title, season, episode) ⇒ Object
- .watchlist(show, episodes) ⇒ Object
Class Method Details
.comments(title, season, episode) ⇒ Object
show-episode GET methods
10 11 12 13 14 15 16 17 |
# File 'lib/traktr/show/episode.rb', line 10 def self.comments(title, season, episode) response = self.get("/" + File.join("comments.json", Traktr.api_key, title, season.to_s, episode.to_s)) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |comment| Mash.new(comment) end end |
.library(show, episodes) ⇒ Object
show-episode POST methods
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/traktr/show/episode.rb', line 39 def self.library(show, episodes) data = { username: Traktr.username, password: Traktr.password, title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id, episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } } } 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(response.parsed_response) end |
.seen(show, episodes) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/traktr/show/episode.rb', line 63 def self.seen(show, episodes) data = { username: Traktr.username, password: Traktr.password, title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id, episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } } } 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(response.parsed_response) end |
.summary(title, season, episode) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/traktr/show/episode.rb', line 19 def self.summary(title, season, episode) response = self.get("/" + File.join("summary.json", Traktr.api_key, title, season.to_s, episode.to_s)) raise ResponseError.new(response) if response.code != 200 Mash.new(response.parsed_response) end |
.unlibrary(show, episodes) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/traktr/show/episode.rb', line 51 def self.unlibrary(show, episodes) data = { username: Traktr.username, password: Traktr.password, title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id, episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } } } 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(show, episodes) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/traktr/show/episode.rb', line 75 def self.unseen(show, episodes) data = { username: Traktr.username, password: Traktr.password, title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id, episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } } } 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(show, episodes) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/traktr/show/episode.rb', line 99 def self.unwatchlist(show, episodes) data = { username: Traktr.username, password: Traktr.password, title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id, episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } } } 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, season, episode) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/traktr/show/episode.rb', line 26 def self.watchingnow(title, season, episode) response = self.get("/" + File.join("watchingnow.json", Traktr.api_key, title, season.to_s, episode.to_s)) raise ResponseError.new(response) if response.code != 200 response.parsed_response.collect do |user| Mash.new(user) end end |
.watchlist(show, episodes) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/traktr/show/episode.rb', line 87 def self.watchlist(show, episodes) data = { username: Traktr.username, password: Traktr.password, title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id, episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } } } 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(response.parsed_response) end |