Class: Traktr::Show::Episode

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/traktr/show/episode.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Episode

Returns a new instance of Episode.



7
8
9
# File 'lib/traktr/show/episode.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#comments(title, season, episode) ⇒ Object

show-episode GET methods

Raises:

  • (ResponseError)


14
15
16
17
18
19
20
21
# File 'lib/traktr/show/episode.rb', line 14

def comments(title, season, episode)
  response = self.class.get("/" + File.join("comments.json", @client.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

Raises:

  • (ResponseError)


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/traktr/show/episode.rb', line 43

def library(show, episodes)
  data = {
      username: @client.username, password: @client.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.class.post("/" + File.join("library", @client.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

Raises:

  • (ResponseError)


67
68
69
70
71
72
73
74
75
76
77
# File 'lib/traktr/show/episode.rb', line 67

def seen(show, episodes)
  data = {
      username: @client.username, password: @client.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.class.post("/" + File.join("seen", @client.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

Raises:

  • (ResponseError)


23
24
25
26
27
28
# File 'lib/traktr/show/episode.rb', line 23

def summary(title, season, episode)
  response = self.class.get("/" + File.join("summary.json", @client.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

Raises:

  • (ResponseError)


55
56
57
58
59
60
61
62
63
64
65
# File 'lib/traktr/show/episode.rb', line 55

def unlibrary(show, episodes)
  data = {
      username: @client.username, password: @client.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.class.post("/" + File.join("unlibrary", @client.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

Raises:

  • (ResponseError)


79
80
81
82
83
84
85
86
87
88
89
# File 'lib/traktr/show/episode.rb', line 79

def unseen(show, episodes)
  data = {
      username: @client.username, password: @client.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.class.post("/" + File.join("unseen", @client.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

Raises:

  • (ResponseError)


103
104
105
106
107
108
109
110
111
112
113
# File 'lib/traktr/show/episode.rb', line 103

def unwatchlist(show, episodes)
  data = {
      username: @client.username, password: @client.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.class.post("/" + File.join("unwatchlist", @client.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

Raises:

  • (ResponseError)


30
31
32
33
34
35
36
37
# File 'lib/traktr/show/episode.rb', line 30

def watchingnow(title, season, episode)
  response = self.class.get("/" + File.join("watchingnow.json", @client.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

Raises:

  • (ResponseError)


91
92
93
94
95
96
97
98
99
100
101
# File 'lib/traktr/show/episode.rb', line 91

def watchlist(show, episodes)
  data = {
      username: @client.username, password: @client.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.class.post("/" + File.join("watchlist", @client.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