traktr 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 87390976f84358a6236208de72b90d71055a7d1d
4
+ data.tar.gz: 1df1bbc628b561be2beaae6127635c5df6df74a5
5
+ SHA512:
6
+ metadata.gz: 6559b2da66ca5c7860d2c63c62faa09ebaa8947467e543c1ac6e12fc52611cda4383470571c4de9ec4e9149934ddd4a221eca6f3205df867b779e5d9b393769d
7
+ data.tar.gz: 8765703ff0a810671c37cab2a5353ed3b4fe02b4dbdedb5c13c495af12e78d46177f24c1ec3b8fd4523a5e68d06a7a4f269ead1cb02496ce5553f0a5393911e1
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in traktr.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Joe Lanford
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Traktr
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'traktr'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install traktr
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ module Traktr
2
+ module Account
3
+ include HTTParty
4
+ base_uri File.join(Traktr.base_uri, "account")
5
+
6
+ def self.settings
7
+ data = { username: Traktr.username, password: Traktr.password }
8
+ response = self.post("/" + File.join("settings", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
9
+ raise ResponseError.new(response) if response.code != 200
10
+
11
+ Mash.new(response.parsed_response)
12
+ end
13
+
14
+ def self.test
15
+ data = { username: Traktr.username, password: Traktr.password }
16
+ response = self.post("/" + File.join("test", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
17
+ raise ResponseError.new(response) if response.code != 200
18
+
19
+ Mash.new(response.parsed_response)
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'digest/sha1'
2
+
3
+ module Traktr
4
+ class << self
5
+ def api_key
6
+ @api_key ||= ""
7
+ end
8
+
9
+ def api_key=(api_key)
10
+ @api_key = api_key
11
+ end
12
+
13
+ def username
14
+ @username ||= ""
15
+ end
16
+
17
+ def username=(username)
18
+ @username = username
19
+ end
20
+
21
+ def password
22
+ @password ||= ""
23
+ end
24
+
25
+ def password=(password)
26
+ @password = password == '' ? '' : Digest::SHA1.hexdigest(password)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,128 @@
1
+ module Traktr
2
+ module Movie
3
+ include HTTParty
4
+ base_uri File.join(Traktr.base_uri, 'movie')
5
+
6
+ ##
7
+ ## movie GET methods
8
+ ##
9
+ def self.comments(title, type = :all)
10
+ response = self.get('/' + File.join('comments.json', Traktr.api_key, title, type.to_s))
11
+ raise ResponseError.new(response) if response.code != 200
12
+
13
+ response.parsed_response.collect do |comment|
14
+ Mash.new(comment)
15
+ end
16
+ end
17
+
18
+ def self.related(title, hidewatched = false)
19
+ response = self.get('/' + File.join('related.json', Traktr.api_key, title, hidewatched.to_s))
20
+ raise ResponseError.new(response) if response.code != 200
21
+
22
+ response.parsed_response.collect do |summary|
23
+ Mash.new(summary)
24
+ end
25
+ end
26
+
27
+ def self.summary(title, extended = :min)
28
+ response = self.get('/' + File.join('summary.json', Traktr.api_key, title.to_s, extended.to_s))
29
+ raise ResponseError.new(response) if response.code != 200
30
+
31
+ Mash.new(response.parsed_response)
32
+ end
33
+
34
+ def self.summaries(titles, extended = :min)
35
+ titles = [titles] if titles.class == String
36
+ response = self.get('/' + File.join('summaries.json', Traktr.api_key, titles.join(','), extended.to_s))
37
+ raise ResponseError.new(response) if response.code != 200
38
+
39
+ response.parsed_response.collect do |summary|
40
+ Mash.new(summary)
41
+ end
42
+ end
43
+
44
+ def self.watchingnow(title)
45
+ response = self.get('/' + File.join('watchingnow.json', Traktr.api_key, title))
46
+ raise ResponseError.new(response) if response.code != 200
47
+
48
+ response.parsed_response.collect do |user|
49
+ Mash.new(user)
50
+ end
51
+ end
52
+
53
+ ##
54
+ ## movie POST methods
55
+ ##
56
+ def self.library(movies)
57
+ movies = [ movies ] if movies.class != Array
58
+ data = {
59
+ username: Traktr.username, password: Traktr.password,
60
+ movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
61
+ }
62
+ response = self.post('/' + File.join('library', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
63
+ raise ResponseError.new(response) if response.code != 200
64
+
65
+ Mash.new(JSON.parse(response.parsed_response))
66
+ end
67
+
68
+ def self.unlibrary(movies)
69
+ movies = [ movies ] if movies.class != Array
70
+ data = {
71
+ username: Traktr.username, password: Traktr.password,
72
+ movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
73
+ }
74
+ response = self.post('/' + File.join('unlibrary', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
75
+ raise ResponseError.new(response) if response.code != 200
76
+
77
+ Mash.new(response.parsed_response)
78
+ end
79
+
80
+ def self.watchlist(movies)
81
+ movies = [ movies ] if movies.class != Array
82
+ data = {
83
+ username: Traktr.username, password: Traktr.password,
84
+ movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
85
+ }
86
+ response = self.post('/' + File.join('watchlist', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
87
+ raise ResponseError.new(response) if response.code != 200
88
+
89
+ Mash.new(JSON.parse(response.parsed_response))
90
+ end
91
+
92
+ def self.unwatchlist(movies)
93
+ movies = [ movies ] if movies.class != Array
94
+ data = {
95
+ username: Traktr.username, password: Traktr.password,
96
+ movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
97
+ }
98
+ response = self.post('/' + File.join('unwatchlist', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
99
+ raise ResponseError.new(response) if response.code != 200
100
+
101
+ Mash.new(response.parsed_response)
102
+ end
103
+
104
+ def self.seen(movies)
105
+ movies = [ movies ] if movies.class != Array
106
+ data = {
107
+ username: Traktr.username, password: Traktr.password,
108
+ movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
109
+ }
110
+ response = self.post('/' + File.join('seen', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
111
+ raise ResponseError.new(response) if response.code != 200
112
+
113
+ Mash.new(JSON.parse(response.parsed_response))
114
+ end
115
+
116
+ def self.unseen(movies)
117
+ movies = [ movies ] if movies.class != Array
118
+ data = {
119
+ username: Traktr.username, password: Traktr.password,
120
+ movies: movies.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tmdb_id: s.tmdb_id }}
121
+ }
122
+ response = self.post('/' + File.join('unseen', Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
123
+ raise ResponseError.new(response) if response.code != 200
124
+
125
+ Mash.new(response.parsed_response)
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,55 @@
1
+ module Traktr
2
+ module Search
3
+ include HTTParty
4
+ base_uri File.join(Traktr.base_uri, 'search')
5
+
6
+ ##
7
+ ## search GET methods
8
+ ##
9
+ def self.episodes(query)
10
+ response = self.get('/' + File.join('episodes.json', Traktr.api_key, URI::encode(query)))
11
+ raise ResponseError.new(response) if response.code != 200
12
+
13
+ response.parsed_response.collect do |result|
14
+ Mash.new(result)
15
+ end
16
+ end
17
+
18
+ def self.movies(query)
19
+ response = self.get('/' + File.join('movies.json', Traktr.api_key, URI::encode(query)))
20
+ raise ResponseError.new(response) if response.code != 200
21
+
22
+ response.parsed_response.collect do |result|
23
+ Mash.new(result)
24
+ end
25
+ end
26
+
27
+ def self.people(query)
28
+ response = self.get('/' + File.join('people.json', Traktr.api_key, URI::encode(query)))
29
+ raise ResponseError.new(response) if response.code != 200
30
+
31
+ response.parsed_response.collect do |result|
32
+ Mash.new(result)
33
+ end
34
+ end
35
+
36
+ def self.shows(query)
37
+ response = self.get('/' + File.join('shows.json', Traktr.api_key, URI::encode(query)))
38
+ raise ResponseError.new(response) if response.code != 200
39
+
40
+ response.parsed_response.collect do |result|
41
+ Mash.new(result)
42
+ end
43
+ end
44
+
45
+ def self.users(query)
46
+ response = self.get('/' + File.join('users.json', Traktr.api_key, URI::encode(query)))
47
+ raise ResponseError.new(response) if response.code != 200
48
+
49
+ response.parsed_response.collect do |result|
50
+ Mash.new(result)
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,112 @@
1
+ module Traktr
2
+ module Show
3
+ module Episode
4
+ include HTTParty
5
+ base_uri File.join(Traktr::Show.base_uri, "episode")
6
+
7
+ ##
8
+ ## show-episode GET methods
9
+ ##
10
+ def self.comments(title, season, episode)
11
+ response = self.get("/" + File.join("comments.json", Traktr.api_key, title, season.to_s, episode.to_s))
12
+ raise ResponseError.new(response) if response.code != 200
13
+
14
+ response.parsed_response.collect do |comment|
15
+ Mash.new(comment)
16
+ end
17
+ end
18
+
19
+ def self.summary(title, season, episode)
20
+ response = self.get("/" + File.join("summary.json", Traktr.api_key, title, season.to_s, episode.to_s))
21
+ raise ResponseError.new(response) if response.code != 200
22
+
23
+ Mash.new(response.parsed_response)
24
+ end
25
+
26
+ def self.watchingnow(title, season, episode)
27
+ response = self.get("/" + File.join("watchingnow.json", Traktr.api_key, title, season.to_s, episode.to_s))
28
+ raise ResponseError.new(response) if response.code != 200
29
+
30
+ response.parsed_response.collect do |user|
31
+ Mash.new(user)
32
+ end
33
+ end
34
+
35
+
36
+ ##
37
+ ## show-episode POST methods
38
+ ##
39
+ def self.library(show, episodes)
40
+ data = {
41
+ username: Traktr.username, password: Traktr.password,
42
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
43
+ episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } }
44
+ }
45
+ response = self.post("/" + File.join("library", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
46
+ raise ResponseError.new(response) if response.code != 200
47
+
48
+ Mash.new(response.parsed_response)
49
+ end
50
+
51
+ def self.unlibrary(show, episodes)
52
+ data = {
53
+ username: Traktr.username, password: Traktr.password,
54
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
55
+ episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } }
56
+ }
57
+ response = self.post("/" + File.join("unlibrary", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
58
+ raise ResponseError.new(response) if response.code != 200
59
+
60
+ Mash.new(response.parsed_response)
61
+ end
62
+
63
+ def self.seen(show, episodes)
64
+ data = {
65
+ username: Traktr.username, password: Traktr.password,
66
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
67
+ episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } }
68
+ }
69
+ response = self.post("/" + File.join("seen", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
70
+ raise ResponseError.new(response) if response.code != 200
71
+
72
+ Mash.new(response.parsed_response)
73
+ end
74
+
75
+ def self.unseen(show, episodes)
76
+ data = {
77
+ username: Traktr.username, password: Traktr.password,
78
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
79
+ episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } }
80
+ }
81
+ response = self.post("/" + File.join("unseen", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
82
+ raise ResponseError.new(response) if response.code != 200
83
+
84
+ Mash.new(response.parsed_response)
85
+ end
86
+
87
+ def self.watchlist(show, episodes)
88
+ data = {
89
+ username: Traktr.username, password: Traktr.password,
90
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
91
+ episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } }
92
+ }
93
+ response = self.post("/" + File.join("watchlist", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
94
+ raise ResponseError.new(response) if response.code != 200
95
+
96
+ Mash.new(response.parsed_response)
97
+ end
98
+
99
+ def self.unwatchlist(show, episodes)
100
+ data = {
101
+ username: Traktr.username, password: Traktr.password,
102
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
103
+ episodes: episodes.collect{ |e| { season: e.season, episode: e.episode } }
104
+ }
105
+ response = self.post("/" + File.join("unwatchlist", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
106
+ raise ResponseError.new(response) if response.code != 200
107
+
108
+ Mash.new(response.parsed_response)
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,36 @@
1
+ module Traktr
2
+ module Show
3
+ module Season
4
+ include HTTParty
5
+ base_uri File.join(Traktr::Show.base_uri, "season")
6
+
7
+ ##
8
+ ## show-season POST methods
9
+ ##
10
+ def self.library(show, season)
11
+ data = {
12
+ username: Traktr.username, password: Traktr.password,
13
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
14
+ season: season
15
+ }
16
+ response = self.post("/" + File.join("library", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
17
+ raise ResponseError.new(response) if response.code != 200
18
+
19
+ Mash.new(response.parsed_response)
20
+ end
21
+
22
+ def self.seen(show, season)
23
+ data = {
24
+ username: Traktr.username, password: Traktr.password,
25
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
26
+ season: season
27
+ }
28
+ response = self.post("/" + File.join("seen", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
29
+ raise ResponseError.new(response) if response.code != 200
30
+
31
+ Mash.new(response.parsed_response)
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,134 @@
1
+ module Traktr
2
+ module Show
3
+ include HTTParty
4
+ base_uri File.join(Traktr.base_uri, "show")
5
+
6
+ ##
7
+ ## show GET methods
8
+ ##
9
+ def self.comments(title, type = :all)
10
+ response = self.get("/" + File.join("comments.json", Traktr.api_key, title, type.to_s))
11
+ raise ResponseError.new(response) if response.code != 200
12
+
13
+ response.parsed_response.collect do |comment|
14
+ Mash.new(comment)
15
+ end
16
+ end
17
+
18
+ def self.related(title, hidewatched = false)
19
+ response = self.get("/" + File.join("related.json", Traktr.api_key, title, hidewatched.to_s))
20
+ raise ResponseError.new(response) if response.code != 200
21
+
22
+ response.parsed_response.collect do |summary|
23
+ Mash.new(summary)
24
+ end
25
+ end
26
+
27
+ def self.season(title, season)
28
+ response = self.get("/" + File.join("season.json", Traktr.api_key, title, season.to_s))
29
+ raise ResponseError.new(response) if response.code != 200
30
+
31
+ response.parsed_response.collect do |episode|
32
+ Mash.new(episode)
33
+ end
34
+ end
35
+
36
+ def self.seasons(title)
37
+ response = self.get("/" + File.join("seasons.json", Traktr.api_key, title))
38
+ raise ResponseError.new(response) if response.code != 200
39
+
40
+ response.parsed_response.collect do |season|
41
+ Mash.new(season)
42
+ end
43
+ end
44
+
45
+ def self.summary(title, extended = :min)
46
+ response = self.get("/" + File.join("summary.json", Traktr.api_key, title, extended.to_s))
47
+ raise ResponseError.new(response) if response.code != 200
48
+
49
+ Mash.new(response.parsed_response)
50
+ end
51
+
52
+ def self.summaries(titles, extended = :min)
53
+ titles = [titles] if titles.class == String
54
+ response = self.get("/" + File.join("summaries.json", Traktr.api_key, titles.join(","), extended.to_s))
55
+ raise ResponseError.new(response) if response.code != 200
56
+
57
+ response.parsed_response.collect do |summary|
58
+ Mash.new(summary)
59
+ end
60
+ end
61
+
62
+ def self.watchingnow(title)
63
+ response = self.get("/" + File.join("watchingnow.json", Traktr.api_key, title))
64
+ raise ResponseError.new(response) if response.code != 200
65
+
66
+ response.parsed_response.collect do |user|
67
+ Mash.new(user)
68
+ end
69
+ end
70
+
71
+ ##
72
+ ## show POST methods
73
+ ##
74
+ def self.library(show)
75
+ data = {
76
+ username: Traktr.username, password: Traktr.password,
77
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
78
+ }
79
+ response = self.post("/" + File.join("library", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
80
+ raise ResponseError.new(response) if response.code != 200
81
+
82
+ Mash.new(response.parsed_response)
83
+ end
84
+
85
+ def self.unlibrary(show)
86
+ data = {
87
+ username: Traktr.username, password: Traktr.password,
88
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
89
+ }
90
+ response = self.post("/" + File.join("unlibrary", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
91
+ raise ResponseError.new(response) if response.code != 200
92
+
93
+ Mash.new(response.parsed_response)
94
+ end
95
+
96
+ def self.watchlist(shows)
97
+ shows = [ shows ] if shows.class != Array
98
+ data = {
99
+ username: Traktr.username, password: Traktr.password,
100
+ shows: shows.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tvdb_id: s.tvdb_id }}
101
+ }
102
+ response = self.post("/" + File.join("watchlist", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
103
+ raise ResponseError.new(response) if response.code != 200
104
+
105
+ Mash.new(JSON.parse(response.parsed_response))
106
+ end
107
+
108
+ def self.unwatchlist(shows)
109
+ shows = [ shows ] if shows.class != Array
110
+ data = {
111
+ username: Traktr.username, password: Traktr.password,
112
+ shows: shows.collect{ |s| { title: s.title, year: s.year, imdb_id: s.imdb_id, tvdb_id: s.tvdb_id }}
113
+ }
114
+ response = self.post("/" + File.join("unwatchlist", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
115
+ raise ResponseError.new(response) if response.code != 200
116
+
117
+ Mash.new(response.parsed_response)
118
+ end
119
+
120
+ def self.seen(show)
121
+ data = {
122
+ username: Traktr.username, password: Traktr.password,
123
+ title: show.title, year: show.year, imdb_id: show.imdb_id, tvdb_id: show.tvdb_id,
124
+ }
125
+ response = self.post("/" + File.join("seen", Traktr.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
126
+ raise ResponseError.new(response) if response.code != 200
127
+
128
+ Mash.new(response.parsed_response)
129
+ end
130
+ end
131
+ end
132
+
133
+ require 'traktr/show/episode'
134
+ require 'traktr/show/season'
@@ -0,0 +1,18 @@
1
+ module Traktr
2
+ module User
3
+ module Calendar
4
+ include HTTParty
5
+ base_uri File.join(Traktr::User.base_uri, 'calendar')
6
+
7
+ def self.shows(username = Traktr.username, date = Date.today, days = 7)
8
+ date = date.strftime('%Y%m%d') if date.class == Date
9
+ response = self.get('/' + File.join('shows.json', Traktr.api_key, username, date, days.to_s))
10
+ raise ResponseError.new(response) if response.code != 200
11
+
12
+ response.parsed_response.collect do |item|
13
+ Mash.new(item)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ module Traktr
2
+ module User
3
+ module Library
4
+ module Movies
5
+ include HTTParty
6
+ base_uri File.join(Traktr::User::Library.base_uri, 'movies')
7
+
8
+ def self.all(username = Traktr.username, extended = :min)
9
+ response = self.get('/' + File.join('all.json', Traktr.api_key, username, extended.to_s))
10
+ raise ResponseError.new(response) if response.code != 200
11
+
12
+ response.parsed_response.collect do |item|
13
+ Mash.new(item)
14
+ end
15
+ end
16
+
17
+ def self.collection(username = Traktr.username, extended = :min)
18
+ response = self.get('/' + File.join('collection.json', Traktr.api_key, username, extended.to_s))
19
+ raise ResponseError.new(response) if response.code != 200
20
+
21
+ response.parsed_response.collect do |item|
22
+ Mash.new(item)
23
+ end
24
+ end
25
+
26
+ def self.watched(username = Traktr.username, extended = :min)
27
+ response = self.get('/' + File.join('watched.json', Traktr.api_key, username, extended.to_s))
28
+ raise ResponseError.new(response) if response.code != 200
29
+
30
+ response.parsed_response.collect do |item|
31
+ Mash.new(item)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end