traktr 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -0
- data/lib/traktr.rb +1 -2
- data/lib/traktr/account.rb +5 -18
- data/lib/traktr/activity.rb +20 -45
- data/lib/traktr/activity/user.rb +12 -27
- data/lib/traktr/calendar.rb +13 -0
- data/lib/traktr/client.rb +52 -1
- data/lib/traktr/comment.rb +18 -0
- data/lib/traktr/endpoint.rb +38 -0
- data/lib/traktr/genres.rb +11 -0
- data/lib/traktr/lists.rb +22 -0
- data/lib/traktr/lists/items.rb +15 -0
- data/lib/traktr/movie.rb +29 -93
- data/lib/traktr/movies.rb +4 -22
- data/lib/traktr/network.rb +27 -0
- data/lib/traktr/rate.rb +30 -0
- data/lib/traktr/recommendations.rb +19 -0
- data/lib/traktr/search.rb +11 -46
- data/lib/traktr/server.rb +7 -0
- data/lib/traktr/show.rb +32 -99
- data/lib/traktr/show/episode.rb +13 -54
- data/lib/traktr/show/season.rb +3 -20
- data/lib/traktr/shows.rb +4 -22
- data/lib/traktr/user.rb +33 -36
- data/lib/traktr/user/calendar.rb +4 -12
- data/lib/traktr/user/library.rb +9 -7
- data/lib/traktr/user/library/movies.rb +6 -24
- data/lib/traktr/user/library/shows.rb +6 -24
- data/lib/traktr/user/network.rb +5 -23
- data/lib/traktr/user/progress.rb +4 -17
- data/lib/traktr/user/ratings.rb +5 -23
- data/lib/traktr/user/watchlist.rb +5 -23
- data/lib/traktr/version.rb +1 -1
- data/spec/calendar_spec.rb +78 -0
- data/spec/comment_spec.rb +65 -0
- data/spec/genres_spec.rb +33 -0
- data/spec/lists_items_spec.rb +65 -0
- data/spec/lists_spec.rb +64 -0
- data/spec/movie_spec.rb +8 -0
- data/spec/network_spec.rb +94 -0
- data/spec/rate_spec.rb +110 -0
- data/spec/recommendations_spec.rb +71 -0
- data/spec/server_spec.rb +25 -0
- data/spec/show_episode_spec.rb +8 -0
- data/spec/show_spec.rb +12 -0
- data/spec/spec.yaml.sample +11 -4
- data/spec/spec_helper.rb +13 -4
- data/spec/user_calendar_spec.rb +51 -0
- data/spec/user_library_movies_spec.rb +59 -0
- data/spec/user_library_shows_spec.rb +59 -0
- data/spec/user_network_spec.rb +59 -0
- data/spec/user_progress_spec.rb +47 -0
- data/spec/user_ratings_spec.rb +59 -0
- data/spec/user_spec.rb +115 -0
- data/spec/user_watchlist_spec.rb +59 -0
- metadata +46 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db67a432e2a5b6097971f8c15ae75f5932a3e074
|
4
|
+
data.tar.gz: 0a9c53bb550ff334c20b8748ca60d385c98f0397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac01b20430e9209469e3172db3fbf8aeb40b7db919c1990493aaf4e1b6b138a02a6c1e0bda6d27df2e7aa19f7e4cf73c85366a7177e5ce09bc744e3f1074478
|
7
|
+
data.tar.gz: c262df780c94cfa49753eab8c458e075b291fee20e40bdc9e34e79f6a76cf257bb096cdae2773182137a6c63b1946e262b71e4a49e75282c7ba116c6dc550e27
|
data/Rakefile
CHANGED
data/lib/traktr.rb
CHANGED
data/lib/traktr/account.rb
CHANGED
@@ -1,26 +1,13 @@
|
|
1
1
|
module Traktr
|
2
|
-
class Account
|
3
|
-
include HTTParty
|
4
|
-
base_uri File.join(Traktr.base_uri, "account")
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
9
|
-
|
2
|
+
class Account < Endpoint
|
10
3
|
def settings
|
11
|
-
|
12
|
-
response
|
13
|
-
raise ResponseError.new(response) if response.code != 200
|
14
|
-
|
15
|
-
Mash.new(response.parsed_response)
|
4
|
+
response = self.class.post("/" + File.join("settings", @client.api_key), body: @auth.to_json, headers: { 'Content-Type' => 'application/json'})
|
5
|
+
parse_response(response)
|
16
6
|
end
|
17
7
|
|
18
8
|
def test
|
19
|
-
|
20
|
-
response
|
21
|
-
raise ResponseError.new(response) if response.code != 200
|
22
|
-
|
23
|
-
Mash.new(response.parsed_response)
|
9
|
+
response = self.class.post("/" + File.join("test", @client.api_key), body: @auth.to_json, headers: { 'Content-Type' => 'application/json'})
|
10
|
+
parse_response(response)
|
24
11
|
end
|
25
12
|
end
|
26
13
|
end
|
data/lib/traktr/activity.rb
CHANGED
@@ -1,70 +1,45 @@
|
|
1
1
|
module Traktr
|
2
|
-
class Activity
|
3
|
-
include HTTParty
|
4
|
-
base_uri File.join(Traktr.base_uri, 'activity')
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
9
|
-
|
10
|
-
##
|
11
|
-
## activity GET methods
|
12
|
-
##
|
2
|
+
class Activity < Endpoint
|
13
3
|
def community(types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
Mash.new(response.parsed_response)
|
4
|
+
types = types.class == Array ? types.join(",") : types.to_s
|
5
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
6
|
+
parse_response self.class.get('/' + File.join('community.json', @client.api_key, types, actions, start_ts.to_s, end_ts.to_s))
|
18
7
|
end
|
19
8
|
|
20
9
|
def episodes(title, season, episode, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
Mash.new(response.parsed_response)
|
25
|
-
end
|
10
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
11
|
+
parse_response self.class.get('/' + File.join('episodes.json', @client.api_key, title, season.to_s, episode.to_s, actions, start_ts.to_s, end_ts.to_s))
|
12
|
+
end
|
26
13
|
|
27
14
|
def movies(title, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
Mash.new(response.parsed_response)
|
15
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
16
|
+
parse_response self.class.get('/' + File.join('movies.json', @client.api_key, title, actions, start_ts.to_s, end_ts.to_s))
|
32
17
|
end
|
33
18
|
|
34
19
|
def seasons(title, season, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
Mash.new(response.parsed_response)
|
20
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
21
|
+
parse_response self.class.get('/' + File.join('seasons.json', @client.api_key, title, season.to_s, actions, start_ts.to_s, end_ts.to_s))
|
39
22
|
end
|
40
23
|
|
41
24
|
def shows(title, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
Mash.new(response.parsed_response)
|
25
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
26
|
+
parse_response self.class.get('/' + File.join('shows.json', @client.api_key, title, actions, start_ts.to_s, end_ts.to_s))
|
46
27
|
end
|
47
28
|
|
48
29
|
def user(username = nil, types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
49
30
|
if username
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
Mash.new(response.parsed_response)
|
31
|
+
types = types.class == Array ? types.join(",") : types.to_s
|
32
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
33
|
+
parse_response self.class.get('/' + File.join('user.json', @client.api_key, username, types, actions, start_ts.to_s, end_ts.to_s))
|
54
34
|
else
|
55
35
|
@user ||= Traktr::Activity::User.new(@client)
|
56
36
|
end
|
57
37
|
end
|
58
38
|
|
59
|
-
##
|
60
|
-
## activity POST methods
|
61
|
-
##
|
62
39
|
def friends(types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
Mash.new(response.parsed_response)
|
68
|
-
end
|
40
|
+
types = types.class == Array ? types.join(",") : types.to_s
|
41
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
42
|
+
parse_response self.class.post('/' + File.join('friends.json', @client.api_key, types, actions, start_ts.to_s, end_ts.to_s), body: @auth.to_json, headers: { 'Content-Type' => 'application/json'})
|
43
|
+
end
|
69
44
|
end
|
70
45
|
end
|
data/lib/traktr/activity/user.rb
CHANGED
@@ -1,40 +1,25 @@
|
|
1
1
|
module Traktr
|
2
2
|
class Activity
|
3
|
-
class User
|
4
|
-
include HTTParty
|
5
|
-
base_uri File.join(Traktr::Activity.base_uri, "user")
|
6
|
-
|
7
|
-
def initialize(client)
|
8
|
-
@client = client
|
9
|
-
end
|
10
|
-
|
3
|
+
class User < Endpoint
|
11
4
|
def episodes(username, title, season, episode, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Mash.new(response.parsed_response)
|
16
|
-
end
|
5
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
6
|
+
parse_response self.class.get('/' + File.join('episodes.json', @client.api_key, username, title, season.to_s, episode.to_s, actions, start_ts.to_s, end_ts.to_s))
|
7
|
+
end
|
17
8
|
|
18
9
|
def movies(username, title, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Mash.new(response.parsed_response)
|
10
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
11
|
+
parse_response self.class.get('/' + File.join('movies.json', @client.api_key, username, title, actions, start_ts.to_s, end_ts.to_s))
|
23
12
|
end
|
24
13
|
|
25
14
|
def seasons(username, title, season, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Mash.new(response.parsed_response)
|
15
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
16
|
+
parse_response self.class.get('/' + File.join('seasons.json', @client.api_key, username, title, season.to_s, actions, start_ts.to_s, end_ts.to_s))
|
30
17
|
end
|
31
18
|
|
32
19
|
def shows(username, title, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
Mash.new(response.parsed_response)
|
37
|
-
end
|
20
|
+
actions = actions.class == Array ? actions.join(",") : actions.to_s
|
21
|
+
parse_response self.class.get('/' + File.join('shows.json', @client.api_key, username, title, actions, start_ts.to_s, end_ts.to_s))
|
22
|
+
end
|
38
23
|
end
|
39
24
|
end
|
40
|
-
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Traktr
|
2
|
+
class Calendar < Endpoint
|
3
|
+
def premieres(date = Date.today, days = 7)
|
4
|
+
date = date.class == Date ? date.strftime("%Y%m%d") : date.to_s
|
5
|
+
parse_response self.class.get('/' + File.join('premieres.json', @client.api_key, date, days.to_s), :basic_auth => @auth)
|
6
|
+
end
|
7
|
+
|
8
|
+
def shows(date = Date.today, days = 7)
|
9
|
+
date = date.class == Date ? date.strftime("%Y%m%d") : date.to_s
|
10
|
+
parse_response self.class.get('/' + File.join('shows.json', @client.api_key, date, days.to_s), :basic_auth => @auth)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/traktr/client.rb
CHANGED
@@ -1,16 +1,35 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
|
3
|
+
require 'traktr/endpoint'
|
4
|
+
|
3
5
|
require 'traktr/account'
|
4
6
|
require 'traktr/activity'
|
5
7
|
require 'traktr/activity/user'
|
8
|
+
require 'traktr/calendar'
|
9
|
+
require 'traktr/comment'
|
10
|
+
require 'traktr/genres'
|
11
|
+
require 'traktr/lists'
|
12
|
+
require 'traktr/lists/items'
|
6
13
|
require 'traktr/movie'
|
7
14
|
require 'traktr/movies'
|
15
|
+
require 'traktr/network'
|
16
|
+
require 'traktr/rate'
|
17
|
+
require 'traktr/recommendations'
|
8
18
|
require 'traktr/search'
|
19
|
+
require 'traktr/server'
|
9
20
|
require 'traktr/show'
|
10
21
|
require 'traktr/show/episode'
|
11
22
|
require 'traktr/show/season'
|
12
23
|
require 'traktr/shows'
|
13
24
|
require 'traktr/user'
|
25
|
+
require 'traktr/user/calendar'
|
26
|
+
require 'traktr/user/library'
|
27
|
+
require 'traktr/user/library/movies'
|
28
|
+
require 'traktr/user/library/shows'
|
29
|
+
require 'traktr/user/network'
|
30
|
+
require 'traktr/user/progress'
|
31
|
+
require 'traktr/user/ratings'
|
32
|
+
require 'traktr/user/watchlist'
|
14
33
|
require 'traktr/version'
|
15
34
|
|
16
35
|
|
@@ -32,6 +51,26 @@ module Traktr
|
|
32
51
|
@activity ||= Traktr::Activity.new(self)
|
33
52
|
end
|
34
53
|
|
54
|
+
def calendar
|
55
|
+
@calendar ||= Traktr::Calendar.new(self)
|
56
|
+
end
|
57
|
+
|
58
|
+
def comment
|
59
|
+
@comment ||= Traktr::Comment.new(self)
|
60
|
+
end
|
61
|
+
|
62
|
+
def genres
|
63
|
+
@genres ||= Traktr::Genres.new(self)
|
64
|
+
end
|
65
|
+
|
66
|
+
def lists
|
67
|
+
@lists ||= Traktr::Lists.new(self)
|
68
|
+
end
|
69
|
+
|
70
|
+
def network
|
71
|
+
@network ||= Traktr::Network.new(self)
|
72
|
+
end
|
73
|
+
|
35
74
|
def movie
|
36
75
|
@movie ||= Traktr::Movie.new(self)
|
37
76
|
end
|
@@ -40,10 +79,22 @@ module Traktr
|
|
40
79
|
@movies ||= Traktr::Movies.new(self)
|
41
80
|
end
|
42
81
|
|
82
|
+
def rate
|
83
|
+
@rate ||= Traktr::Rate.new(self)
|
84
|
+
end
|
85
|
+
|
86
|
+
def recommendations
|
87
|
+
@recommendations ||= Traktr::Recommendations.new(self)
|
88
|
+
end
|
89
|
+
|
43
90
|
def search
|
44
91
|
@search ||= Traktr::Search.new(self)
|
45
92
|
end
|
46
93
|
|
94
|
+
def server
|
95
|
+
@server ||= Traktr::Server.new(self)
|
96
|
+
end
|
97
|
+
|
47
98
|
def show
|
48
99
|
@show ||= Traktr::Show.new(self)
|
49
100
|
end
|
@@ -60,4 +111,4 @@ module Traktr
|
|
60
111
|
@version ||= Traktr::Version.new(self)
|
61
112
|
end
|
62
113
|
end
|
63
|
-
end
|
114
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Traktr
|
2
|
+
class Comment < Endpoint
|
3
|
+
def episode( data )
|
4
|
+
data.merge!(@auth.merge({ review: data[:comment].split(/\s+/).length > 200 }))
|
5
|
+
parse_response self.class.post('/' + File.join('episode', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
6
|
+
end
|
7
|
+
|
8
|
+
def movie( data )
|
9
|
+
data.merge!(@auth.merge({ review: data[:comment].split(/\s+/).length > 200 }))
|
10
|
+
parse_response self.class.post('/' + File.join('movie', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
11
|
+
end
|
12
|
+
|
13
|
+
def show( data )
|
14
|
+
data.merge!(@auth.merge({ review: data[:comment].split(/\s+/).length > 200 }))
|
15
|
+
parse_response self.class.post('/' + File.join('show', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Traktr
|
2
|
+
class Endpoint
|
3
|
+
include HTTParty
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
self.class.base_uri File.join(Traktr.base_uri, self.class.to_s.split("::")[1..-1].join("/").downcase)
|
7
|
+
@client = client
|
8
|
+
@auth = { username: @client.username, password: @client.password }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def parse_response( response )
|
14
|
+
raise ResponseError.new(response) if response.code != 200
|
15
|
+
data = response.parsed_response
|
16
|
+
if data.class == Array
|
17
|
+
data.collect { |i| Mash.new(i) }
|
18
|
+
elsif data.class == Hash
|
19
|
+
Mash.new(data)
|
20
|
+
elsif data.class == String
|
21
|
+
#
|
22
|
+
# TODO: Trakt's response header's "Content-Type" parameter is sometimes set to "text/html",
|
23
|
+
# but HTTParty needs it to be "application/json" to correctly parse.
|
24
|
+
#
|
25
|
+
# Endpoints with this issue are:
|
26
|
+
# - 'lists/items/add'
|
27
|
+
# - 'movie/library'
|
28
|
+
# - 'movie/watchlist'
|
29
|
+
# - 'movie/seen'
|
30
|
+
# - 'show/watchlist'
|
31
|
+
#
|
32
|
+
Mash.new(JSON.parse(response))
|
33
|
+
else
|
34
|
+
data
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/traktr/lists.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Traktr
|
2
|
+
class Lists < Endpoint
|
3
|
+
def add( data )
|
4
|
+
data.merge!(@auth)
|
5
|
+
parse_response self.class.post('/' + File.join('add', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
6
|
+
end
|
7
|
+
|
8
|
+
def delete( slug )
|
9
|
+
data = @auth.merge({:slug => slug})
|
10
|
+
parse_response self.class.post('/' + File.join('delete', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
11
|
+
end
|
12
|
+
|
13
|
+
def update( slug, data )
|
14
|
+
data.merge!(@auth.merge({:slug => slug}))
|
15
|
+
parse_response self.class.post('/' + File.join('update', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
16
|
+
end
|
17
|
+
|
18
|
+
def items
|
19
|
+
@items ||= Traktr::Lists::Items.new(@client)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Traktr
|
2
|
+
class Lists
|
3
|
+
class Items < Endpoint
|
4
|
+
def add( slug, items )
|
5
|
+
data = @auth.merge({:slug => slug, :items => items.class == Array ? items : [items]})
|
6
|
+
parse_response self.class.post('/' + File.join('add', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
7
|
+
end
|
8
|
+
|
9
|
+
def delete( slug, items )
|
10
|
+
data = @auth.merge({:slug => slug, :items => items.class == Array ? items : [items]})
|
11
|
+
parse_response self.class.post('/' + File.join('delete', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/traktr/movie.rb
CHANGED
@@ -1,132 +1,68 @@
|
|
1
1
|
module Traktr
|
2
|
-
class Movie
|
3
|
-
include HTTParty
|
4
|
-
base_uri File.join(Traktr.base_uri, 'movie')
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
9
|
-
|
10
|
-
##
|
11
|
-
## movie GET methods
|
12
|
-
##
|
2
|
+
class Movie < Endpoint
|
13
3
|
def comments(title, type = :all)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
response.parsed_response.collect do |comment|
|
18
|
-
Mash.new(comment)
|
19
|
-
end
|
4
|
+
type = [:all, :shouts, :reviews].include?(type) ? type.to_s : ""
|
5
|
+
parse_response self.class.get('/' + File.join('comments.json', @client.api_key, title, type))
|
20
6
|
end
|
21
7
|
|
22
|
-
def related(title, hidewatched =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
response.parsed_response.collect do |summary|
|
27
|
-
Mash.new(summary)
|
28
|
-
end
|
8
|
+
def related(title, hidewatched = nil)
|
9
|
+
hidewatched = hidewatched == false || hidewatched == nil ? "" : "hidewatched"
|
10
|
+
parse_response self.class.get('/' + File.join('related.json', @client.api_key, title, hidewatched), :basic_auth => @auth)
|
29
11
|
end
|
30
12
|
|
31
|
-
def
|
32
|
-
|
33
|
-
raise ResponseError.new(response) if response.code != 200
|
34
|
-
|
35
|
-
Mash.new(response.parsed_response)
|
13
|
+
def stats(title)
|
14
|
+
parse_response self.class.get('/' + File.join('stats.json', @client.api_key, title))
|
36
15
|
end
|
37
16
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
17
|
+
def summary(title, extended = nil)
|
18
|
+
extended = [:normal, :full].include?(extended) ? extended.to_s : ""
|
19
|
+
parse_response self.class.get('/' + File.join('summary.json', @client.api_key, title.to_s, extended), :basic_auth => @auth)
|
20
|
+
end
|
42
21
|
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
def summaries(titles, extended = nil)
|
23
|
+
titles = titles.join(",") if titles.class == Array
|
24
|
+
extended = [:normal, :full].include?(extended) ? extended.to_s : ""
|
25
|
+
parse_response self.class.get('/' + File.join('summaries.json', @client.api_key, titles, extended))
|
46
26
|
end
|
47
27
|
|
48
28
|
def watchingnow(title)
|
49
|
-
|
50
|
-
raise ResponseError.new(response) if response.code != 200
|
51
|
-
|
52
|
-
response.parsed_response.collect do |user|
|
53
|
-
Mash.new(user)
|
54
|
-
end
|
29
|
+
parse_response self.class.get('/' + File.join('watchingnow.json', @client.api_key, title), :basic_auth => @auth)
|
55
30
|
end
|
56
31
|
|
57
|
-
##
|
58
|
-
## movie POST methods
|
59
|
-
##
|
60
32
|
def library(movies)
|
61
33
|
movies = [ movies ] if movies.class != Array
|
62
|
-
data = {
|
63
|
-
|
64
|
-
movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
|
65
|
-
}
|
66
|
-
response = self.class.post('/' + File.join('library', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
67
|
-
raise ResponseError.new(response) if response.code != 200
|
68
|
-
|
69
|
-
Mash.new(JSON.parse(response.parsed_response))
|
34
|
+
data = @auth.merge({ :movies => movies })
|
35
|
+
parse_response self.class.post('/' + File.join('library', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
70
36
|
end
|
71
37
|
|
72
38
|
def unlibrary(movies)
|
73
39
|
movies = [ movies ] if movies.class != Array
|
74
|
-
data = {
|
75
|
-
|
76
|
-
movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
|
77
|
-
}
|
78
|
-
response = self.class.post('/' + File.join('unlibrary', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
79
|
-
raise ResponseError.new(response) if response.code != 200
|
80
|
-
|
81
|
-
Mash.new(response.parsed_response)
|
40
|
+
data = @auth.merge({ :movies => movies })
|
41
|
+
parse_response self.class.post('/' + File.join('unlibrary', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
82
42
|
end
|
83
43
|
|
84
44
|
def watchlist(movies)
|
85
45
|
movies = [ movies ] if movies.class != Array
|
86
|
-
data = {
|
87
|
-
|
88
|
-
movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
|
89
|
-
}
|
90
|
-
response = self.class.post('/' + File.join('watchlist', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
91
|
-
raise ResponseError.new(response) if response.code != 200
|
92
|
-
|
93
|
-
Mash.new(JSON.parse(response.parsed_response))
|
46
|
+
data = @auth.merge({ :movies => movies })
|
47
|
+
parse_response self.class.post('/' + File.join('watchlist', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
94
48
|
end
|
95
49
|
|
96
50
|
def unwatchlist(movies)
|
97
51
|
movies = [ movies ] if movies.class != Array
|
98
|
-
data = {
|
99
|
-
|
100
|
-
movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
|
101
|
-
}
|
102
|
-
response = self.class.post('/' + File.join('unwatchlist', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
103
|
-
raise ResponseError.new(response) if response.code != 200
|
104
|
-
|
105
|
-
Mash.new(response.parsed_response)
|
52
|
+
data = @auth.merge({ :movies => movies })
|
53
|
+
parse_response self.class.post('/' + File.join('unwatchlist', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
106
54
|
end
|
107
55
|
|
108
56
|
def seen(movies)
|
109
57
|
movies = [ movies ] if movies.class != Array
|
110
|
-
data = {
|
111
|
-
|
112
|
-
movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
|
113
|
-
}
|
114
|
-
response = self.class.post('/' + File.join('seen', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
115
|
-
raise ResponseError.new(response) if response.code != 200
|
116
|
-
|
117
|
-
Mash.new(JSON.parse(response.parsed_response))
|
58
|
+
data = @auth.merge({ :movies => movies })
|
59
|
+
parse_response self.class.post('/' + File.join('seen', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
118
60
|
end
|
119
61
|
|
120
62
|
def unseen(movies)
|
121
63
|
movies = [ movies ] if movies.class != Array
|
122
|
-
data = {
|
123
|
-
|
124
|
-
movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
|
125
|
-
}
|
126
|
-
response = self.class.post('/' + File.join('unseen', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
127
|
-
raise ResponseError.new(response) if response.code != 200
|
128
|
-
|
129
|
-
Mash.new(response.parsed_response)
|
64
|
+
data = @auth.merge({ :movies => movies })
|
65
|
+
parse_response self.class.post('/' + File.join('unseen', @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
130
66
|
end
|
131
67
|
end
|
132
68
|
end
|