traktr 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/lib/traktr/show/season.rb
CHANGED
@@ -1,26 +1,13 @@
|
|
1
1
|
module Traktr
|
2
2
|
class Show
|
3
|
-
class Season
|
4
|
-
include HTTParty
|
5
|
-
base_uri File.join(Traktr::Show.base_uri, "season")
|
6
|
-
|
7
|
-
def initialize(client)
|
8
|
-
@client = client
|
9
|
-
end
|
10
|
-
|
11
|
-
##
|
12
|
-
## show-season POST methods
|
13
|
-
##
|
3
|
+
class Season < Endpoint
|
14
4
|
def library(show, season)
|
15
5
|
data = {
|
16
6
|
username: @client.username, password: @client.password,
|
17
7
|
title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
|
18
8
|
season: season
|
19
9
|
}
|
20
|
-
|
21
|
-
raise ResponseError.new(response) if response.code != 200
|
22
|
-
|
23
|
-
Mash.new(response.parsed_response)
|
10
|
+
parse_response self.class.post("/" + File.join("library", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
24
11
|
end
|
25
12
|
|
26
13
|
def seen(show, season)
|
@@ -29,12 +16,8 @@ module Traktr
|
|
29
16
|
title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
|
30
17
|
season: season
|
31
18
|
}
|
32
|
-
|
33
|
-
raise ResponseError.new(response) if response.code != 200
|
34
|
-
|
35
|
-
Mash.new(response.parsed_response)
|
19
|
+
parse_response self.class.post("/" + File.join("seen", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
|
36
20
|
end
|
37
|
-
|
38
21
|
end
|
39
22
|
end
|
40
23
|
end
|
data/lib/traktr/shows.rb
CHANGED
@@ -1,30 +1,12 @@
|
|
1
1
|
module Traktr
|
2
|
-
class Shows
|
3
|
-
include HTTParty
|
4
|
-
base_uri File.join(Traktr.base_uri, 'shows')
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
9
|
-
|
10
|
-
##
|
11
|
-
## movies GET methods
|
12
|
-
##
|
2
|
+
class Shows < Endpoint
|
13
3
|
def trending
|
14
|
-
|
15
|
-
raise ResponseError.new(response) if response.code != 200
|
16
|
-
|
17
|
-
response.parsed_response.collect do |show|
|
18
|
-
Mash.new(show)
|
19
|
-
end
|
4
|
+
parse_response self.class.get('/' + File.join('trending.json', @client.api_key), :basic_auth => @auth)
|
20
5
|
end
|
21
6
|
|
22
7
|
def updated(timestamp)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
Mash.new(response.parsed_response)
|
8
|
+
timestamp = timestamp.class == Time ? timestamp.to_i.to_s : timestamp.to_s
|
9
|
+
parse_response self.class.get('/' + File.join('updated.json', @client.api_key, timestamp))
|
27
10
|
end
|
28
|
-
|
29
11
|
end
|
30
12
|
end
|
data/lib/traktr/user.rb
CHANGED
@@ -1,55 +1,52 @@
|
|
1
1
|
module Traktr
|
2
|
-
class User
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
2
|
+
class User < Endpoint
|
3
|
+
def lastactivity(user = @client.username)
|
4
|
+
parse_response self.class.get("/" + File.join("lastactivity.json", @client.api_key, user), :basic_auth => @auth)
|
8
5
|
end
|
9
6
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
7
|
+
def list(slug, user = @client.username)
|
8
|
+
parse_response self.class.get("/" + File.join("list.json", @client.api_key, user, slug), :basic_auth => @auth)
|
9
|
+
end
|
13
10
|
|
14
|
-
|
11
|
+
def lists(user = @client.username)
|
12
|
+
parse_response self.class.get("/" + File.join("lists.json", @client.api_key, user), :basic_auth => @auth)
|
15
13
|
end
|
16
14
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
15
|
+
def profile(user = @client.username)
|
16
|
+
parse_response self.class.get("/" + File.join("profile.json", @client.api_key, user), :basic_auth => @auth)
|
17
|
+
end
|
20
18
|
|
21
|
-
|
19
|
+
def watching(user = @client.username)
|
20
|
+
#
|
21
|
+
# TODO : When the user is protected or not currently watching anything, this
|
22
|
+
# returns an empty array. However, Trakt's documentation makes it seem
|
23
|
+
# like an empty object will be returned
|
24
|
+
#
|
25
|
+
parse_response self.class.get("/" + File.join("watching.json", @client.api_key, user), :basic_auth => @auth)
|
22
26
|
end
|
23
27
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
28
|
+
def calendar
|
29
|
+
@calendar ||= Traktr::User::Calendar.new(@client)
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
end
|
32
|
+
def library
|
33
|
+
@library ||= Traktr::User::Library.new(@client)
|
31
34
|
end
|
32
35
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
+
def network
|
37
|
+
@network ||= Traktr::User::Network.new(@client)
|
38
|
+
end
|
36
39
|
|
37
|
-
|
40
|
+
def progress
|
41
|
+
@progress ||= Traktr::User::Progress.new(@client)
|
38
42
|
end
|
39
43
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
44
|
+
def ratings
|
45
|
+
@ratings ||= Traktr::User::Ratings.new(@client)
|
46
|
+
end
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
48
|
+
def watchlist
|
49
|
+
@watchlist ||= Traktr::User::Watchlist.new(@client)
|
47
50
|
end
|
48
51
|
end
|
49
52
|
end
|
50
|
-
|
51
|
-
#require 'traktr/user/library'
|
52
|
-
#require 'traktr/user/network'
|
53
|
-
#require 'traktr/user/progress'
|
54
|
-
#require 'traktr/user/ratings'
|
55
|
-
#require 'traktr/user/watchlist'
|
data/lib/traktr/user/calendar.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
include HTTParty
|
5
|
-
base_uri File.join(Traktr::User.base_uri, 'calendar')
|
6
|
-
|
2
|
+
class User
|
3
|
+
class Calendar < Endpoint
|
7
4
|
def shows(username = @client.username, date = Date.today, days = 7)
|
8
|
-
date = date.strftime(
|
9
|
-
|
10
|
-
raise ResponseError.new(response) if response.code != 200
|
11
|
-
|
12
|
-
response.parsed_response.collect do |item|
|
13
|
-
Mash.new(item)
|
14
|
-
end
|
5
|
+
date = date.class == Date ? date.strftime("%Y%m%d") : date.to_s
|
6
|
+
parse_response self.class.get('/' + File.join('shows.json', @client.api_key, username, date, days.to_s), :basic_auth => @auth)
|
15
7
|
end
|
16
8
|
end
|
17
9
|
end
|
data/lib/traktr/user/library.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class User
|
3
|
+
class Library < Endpoint
|
4
|
+
def movies
|
5
|
+
@movies ||= Traktr::User::Library::Movies.new(@client)
|
6
|
+
end
|
7
|
+
|
8
|
+
def shows
|
9
|
+
@shows ||= Traktr::User::Library::Shows.new(@client)
|
10
|
+
end
|
6
11
|
end
|
7
12
|
end
|
8
13
|
end
|
9
|
-
|
10
|
-
require 'traktr/user/library/movies'
|
11
|
-
require 'traktr/user/library/shows'
|
@@ -1,35 +1,17 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
include HTTParty
|
6
|
-
base_uri File.join(Traktr::User::Library.base_uri, 'movies')
|
7
|
-
|
2
|
+
class User
|
3
|
+
class Library
|
4
|
+
class Movies < Endpoint
|
8
5
|
def all(username = @client.username, extended = :min)
|
9
|
-
|
10
|
-
raise ResponseError.new(response) if response.code != 200
|
11
|
-
|
12
|
-
response.parsed_response.collect do |item|
|
13
|
-
Mash.new(item)
|
14
|
-
end
|
6
|
+
parse_response self.class.get('/' + File.join('all.json', @client.api_key, username, extended.to_s))
|
15
7
|
end
|
16
8
|
|
17
9
|
def collection(username = @client.username, extended = :min)
|
18
|
-
|
19
|
-
raise ResponseError.new(response) if response.code != 200
|
20
|
-
|
21
|
-
response.parsed_response.collect do |item|
|
22
|
-
Mash.new(item)
|
23
|
-
end
|
10
|
+
parse_response self.class.get('/' + File.join('collection.json', @client.api_key, username, extended.to_s))
|
24
11
|
end
|
25
12
|
|
26
13
|
def watched(username = @client.username, extended = :min)
|
27
|
-
|
28
|
-
raise ResponseError.new(response) if response.code != 200
|
29
|
-
|
30
|
-
response.parsed_response.collect do |item|
|
31
|
-
Mash.new(item)
|
32
|
-
end
|
14
|
+
parse_response self.class.get('/' + File.join('watched.json', @client.api_key, username, extended.to_s))
|
33
15
|
end
|
34
16
|
end
|
35
17
|
end
|
@@ -1,35 +1,17 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
include HTTParty
|
6
|
-
base_uri File.join(Traktr::User::Library.base_uri, 'shows')
|
7
|
-
|
2
|
+
class User
|
3
|
+
class Library
|
4
|
+
class Shows < Endpoint
|
8
5
|
def all(username = @client.username, extended = :min)
|
9
|
-
|
10
|
-
raise ResponseError.new(response) if response.code != 200
|
11
|
-
|
12
|
-
response.parsed_response.collect do |item|
|
13
|
-
Mash.new(item)
|
14
|
-
end
|
6
|
+
parse_response self.class.get('/' + File.join('all.json', @client.api_key, username, extended.to_s))
|
15
7
|
end
|
16
8
|
|
17
9
|
def collection(username = @client.username, extended = :min)
|
18
|
-
|
19
|
-
raise ResponseError.new(response) if response.code != 200
|
20
|
-
|
21
|
-
response.parsed_response.collect do |item|
|
22
|
-
Mash.new(item)
|
23
|
-
end
|
10
|
+
parse_response self.class.get('/' + File.join('collection.json', @client.api_key, username, extended.to_s))
|
24
11
|
end
|
25
12
|
|
26
13
|
def watched(username = @client.username, extended = :min)
|
27
|
-
|
28
|
-
raise ResponseError.new(response) if response.code != 200
|
29
|
-
|
30
|
-
response.parsed_response.collect do |item|
|
31
|
-
Mash.new(item)
|
32
|
-
end
|
14
|
+
parse_response self.class.get('/' + File.join('watched.json', @client.api_key, username, extended.to_s))
|
33
15
|
end
|
34
16
|
end
|
35
17
|
end
|
data/lib/traktr/user/network.rb
CHANGED
@@ -1,34 +1,16 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
include HTTParty
|
5
|
-
base_uri File.join(Traktr::User.base_uri, 'network')
|
6
|
-
|
2
|
+
class User
|
3
|
+
class Network < Endpoint
|
7
4
|
def followers(username = @client.username)
|
8
|
-
|
9
|
-
raise ResponseError.new(response) if response.code != 200
|
10
|
-
|
11
|
-
response.parsed_response.collect do |item|
|
12
|
-
Mash.new(item)
|
13
|
-
end
|
5
|
+
parse_response self.class.get('/' + File.join('followers.json', @client.api_key, username))
|
14
6
|
end
|
15
7
|
|
16
8
|
def following(username = @client.username)
|
17
|
-
|
18
|
-
raise ResponseError.new(response) if response.code != 200
|
19
|
-
|
20
|
-
response.parsed_response.collect do |item|
|
21
|
-
Mash.new(item)
|
22
|
-
end
|
9
|
+
parse_response self.class.get('/' + File.join('following.json', @client.api_key, username))
|
23
10
|
end
|
24
11
|
|
25
12
|
def friends(username = @client.username)
|
26
|
-
|
27
|
-
raise ResponseError.new(response) if response.code != 200
|
28
|
-
|
29
|
-
response.parsed_response.collect do |item|
|
30
|
-
Mash.new(item)
|
31
|
-
end
|
13
|
+
parse_response self.class.get('/' + File.join('friends.json', @client.api_key, username))
|
32
14
|
end
|
33
15
|
end
|
34
16
|
end
|
data/lib/traktr/user/progress.rb
CHANGED
@@ -1,25 +1,12 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
include HTTParty
|
5
|
-
base_uri File.join(Traktr::User.base_uri, 'progress')
|
6
|
-
|
2
|
+
class User
|
3
|
+
class Progress < Endpoint
|
7
4
|
def collected(username = @client.username, title = :all, sort = :title, extended = :min)
|
8
|
-
|
9
|
-
raise ResponseError.new(response) if response.code != 200
|
10
|
-
|
11
|
-
response.parsed_response.collect do |item|
|
12
|
-
Mash.new(item)
|
13
|
-
end
|
5
|
+
parse_response self.class.get('/' + File.join('collected.json', @client.api_key, username, title.to_s, sort.to_s, extended.to_s))
|
14
6
|
end
|
15
7
|
|
16
8
|
def watched(username = @client.username, title = :all, sort = :title, extended = :min)
|
17
|
-
|
18
|
-
raise ResponseError.new(response) if response.code != 200
|
19
|
-
|
20
|
-
response.parsed_response.collect do |item|
|
21
|
-
Mash.new(item)
|
22
|
-
end
|
9
|
+
parse_response self.class.get('/' + File.join('watched.json', @client.api_key, username, title.to_s, sort.to_s, extended.to_s))
|
23
10
|
end
|
24
11
|
end
|
25
12
|
end
|
data/lib/traktr/user/ratings.rb
CHANGED
@@ -1,34 +1,16 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
include HTTParty
|
5
|
-
base_uri File.join(Traktr::User.base_uri, 'ratings')
|
6
|
-
|
2
|
+
class User
|
3
|
+
class Ratings < Endpoint
|
7
4
|
def episodes(username = @client.username, rating = :all, extended = :min)
|
8
|
-
|
9
|
-
raise ResponseError.new(response) if response.code != 200
|
10
|
-
|
11
|
-
response.parsed_response.collect do |item|
|
12
|
-
Mash.new(item)
|
13
|
-
end
|
5
|
+
parse_response self.class.get('/' + File.join('episodes.json', @client.api_key, username, rating.to_s, extended.to_s))
|
14
6
|
end
|
15
7
|
|
16
8
|
def movies(username = @client.username, rating = :all, extended = :min)
|
17
|
-
|
18
|
-
raise ResponseError.new(response) if response.code != 200
|
19
|
-
|
20
|
-
response.parsed_response.collect do |item|
|
21
|
-
Mash.new(item)
|
22
|
-
end
|
9
|
+
parse_response self.class.get('/' + File.join('movies.json', @client.api_key, username, rating.to_s, extended.to_s))
|
23
10
|
end
|
24
11
|
|
25
12
|
def shows(username = @client.username, rating = :all, extended = :min)
|
26
|
-
|
27
|
-
raise ResponseError.new(response) if response.code != 200
|
28
|
-
|
29
|
-
response.parsed_response.collect do |item|
|
30
|
-
Mash.new(item)
|
31
|
-
end
|
13
|
+
parse_response self.class.get('/' + File.join('shows.json', @client.api_key, username, rating.to_s, extended.to_s))
|
32
14
|
end
|
33
15
|
end
|
34
16
|
end
|
@@ -1,34 +1,16 @@
|
|
1
1
|
module Traktr
|
2
|
-
|
3
|
-
|
4
|
-
include HTTParty
|
5
|
-
base_uri File.join(Traktr::User.base_uri, 'watchlist')
|
6
|
-
|
2
|
+
class User
|
3
|
+
class Watchlist < Endpoint
|
7
4
|
def episodes(username = @client.username)
|
8
|
-
|
9
|
-
raise ResponseError.new(response) if response.code != 200
|
10
|
-
|
11
|
-
response.parsed_response.collect do |item|
|
12
|
-
Mash.new(item)
|
13
|
-
end
|
5
|
+
parse_response self.class.get('/' + File.join('episodes.json', @client.api_key, username))
|
14
6
|
end
|
15
7
|
|
16
8
|
def movies(username = @client.username)
|
17
|
-
|
18
|
-
raise ResponseError.new(response) if response.code != 200
|
19
|
-
|
20
|
-
response.parsed_response.collect do |item|
|
21
|
-
Mash.new(item)
|
22
|
-
end
|
9
|
+
parse_response self.class.get('/' + File.join('movies.json', @client.api_key, username))
|
23
10
|
end
|
24
11
|
|
25
12
|
def shows(username = @client.username)
|
26
|
-
|
27
|
-
raise ResponseError.new(response) if response.code != 200
|
28
|
-
|
29
|
-
response.parsed_response.collect do |item|
|
30
|
-
Mash.new(item)
|
31
|
-
end
|
13
|
+
parse_response self.class.get('/' + File.join('shows.json', @client.api_key, username))
|
32
14
|
end
|
33
15
|
end
|
34
16
|
end
|