thetvdb_api 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +72 -1
- data/lib/thetvdb_api.rb +4 -1
- data/lib/thetvdb_api/actor.rb +2 -2
- data/lib/thetvdb_api/banner.rb +2 -2
- data/lib/thetvdb_api/base.rb +30 -9
- data/lib/thetvdb_api/episode.rb +10 -10
- data/lib/thetvdb_api/mappers/actor.rb +17 -0
- data/lib/thetvdb_api/mappers/actors.rb +10 -0
- data/lib/thetvdb_api/mappers/banner.rb +32 -0
- data/lib/thetvdb_api/mappers/banners.rb +10 -0
- data/lib/thetvdb_api/mappers/base.rb +13 -0
- data/lib/thetvdb_api/mappers/episode.rb +32 -0
- data/lib/thetvdb_api/mappers/full_series.rb +12 -0
- data/lib/thetvdb_api/mappers/search_episode.rb +10 -0
- data/lib/thetvdb_api/mappers/search_series.rb +10 -0
- data/lib/thetvdb_api/mappers/search_series/series.rb +25 -0
- data/lib/thetvdb_api/mappers/series.rb +37 -0
- data/lib/thetvdb_api/mappers/update.rb +14 -0
- data/lib/thetvdb_api/mappers/update/banner.rb +19 -0
- data/lib/thetvdb_api/mappers/update/element.rb +10 -0
- data/lib/thetvdb_api/mappers/update/episode.rb +8 -0
- data/lib/thetvdb_api/mappers/update/series.rb +8 -0
- data/lib/thetvdb_api/response.rb +30 -0
- data/lib/thetvdb_api/search.rb +8 -8
- data/lib/thetvdb_api/series.rb +4 -4
- data/lib/thetvdb_api/update.rb +42 -8
- data/lib/thetvdb_api/version.rb +1 -1
- data/spec/integrations/actor_spec.rb +1 -1
- data/spec/integrations/banner_spec.rb +1 -1
- data/spec/integrations/client_spec.rb +16 -16
- data/spec/integrations/episode_spec.rb +4 -4
- data/spec/integrations/search_spec.rb +5 -5
- data/spec/integrations/series_spec.rb +2 -2
- data/spec/integrations/update_spec.rb +10 -4
- data/spec/spec_helper.rb +4 -0
- data/spec/thetvdb_api/base_spec.rb +39 -7
- data/spec/thetvdb_api/episode_spec.rb +4 -4
- data/spec/thetvdb_api/mappers/actor_spec.rb +15 -0
- data/spec/thetvdb_api/mappers/banner_spec.rb +31 -0
- data/spec/thetvdb_api/mappers/search_series/series_spec.rb +15 -0
- data/spec/thetvdb_api/mappers/series_spec.rb +31 -0
- data/spec/thetvdb_api/mappers/update/banner_spec.rb +15 -0
- data/spec/thetvdb_api/response_spec.rb +60 -0
- data/spec/thetvdb_api/search_spec.rb +13 -13
- data/spec/thetvdb_api/series_spec.rb +6 -6
- data/spec/thetvdb_api/update_spec.rb +24 -0
- data/thetvdb_api.gemspec +2 -1
- metadata +48 -5
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'update/banner'
|
3
|
+
require 'update/episode'
|
4
|
+
require 'update/series'
|
5
|
+
|
6
|
+
class ThetvdbApi::Mappers::Update
|
7
|
+
include HappyMapper
|
8
|
+
|
9
|
+
tag 'Data'
|
10
|
+
|
11
|
+
has_many :series, ThetvdbApi::Mappers::Update::Series, tag: 'Series'
|
12
|
+
has_many :episodes, ThetvdbApi::Mappers::Update::Episode, tag: 'Episode'
|
13
|
+
has_many :banners, ThetvdbApi::Mappers::Update::Banner, tag: 'Banner'
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
|
3
|
+
class ThetvdbApi::Mappers::Update
|
4
|
+
class Banner
|
5
|
+
include HappyMapper
|
6
|
+
|
7
|
+
tag 'Banner'
|
8
|
+
element :type, String
|
9
|
+
element :format, String
|
10
|
+
element :series_id, String, tag: 'Series'
|
11
|
+
element :season_num, String, tag: 'SeasonNum'
|
12
|
+
element :language, String
|
13
|
+
element :path, String
|
14
|
+
|
15
|
+
def url
|
16
|
+
path ? "http://thetvdb.com/banners/#{path}" : nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class ThetvdbApi::Response
|
2
|
+
def initialize(faraday_response, mapper = nil)
|
3
|
+
@faraday_response = faraday_response
|
4
|
+
@mapper = mapper
|
5
|
+
end
|
6
|
+
|
7
|
+
def mapper
|
8
|
+
@mapper
|
9
|
+
end
|
10
|
+
|
11
|
+
def env
|
12
|
+
@faraday_response.env
|
13
|
+
end
|
14
|
+
|
15
|
+
def status
|
16
|
+
@faraday_response.status
|
17
|
+
end
|
18
|
+
|
19
|
+
def headers
|
20
|
+
@faraday_response.headers
|
21
|
+
end
|
22
|
+
|
23
|
+
def body
|
24
|
+
@body ||= @mapper ? @mapper.parse(@faraday_response.body) : @faraday_response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
def inspect
|
28
|
+
"<ThetvdbApi::Response body=#{body.inspect}, mapper=#{mapper.inspect}>"
|
29
|
+
end
|
30
|
+
end
|
data/lib/thetvdb_api/search.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
class ThetvdbApi::Search < ThetvdbApi::Base
|
2
|
-
def get_series(name,
|
3
|
-
get('GetSeries.php').params(seriesname: name
|
2
|
+
def get_series(name, options = {})
|
3
|
+
get('GetSeries.php').params({ seriesname: name }.merge(options)).response
|
4
4
|
end
|
5
5
|
|
6
|
-
def get_series_by_imdb_id(id,
|
7
|
-
get('GetSeriesByRemoteID.php').params(imdbid: id
|
6
|
+
def get_series_by_imdb_id(id, options = {})
|
7
|
+
get('GetSeriesByRemoteID.php').params({ imdbid: id }.merge(options)).response
|
8
8
|
end
|
9
9
|
|
10
|
-
def get_series_by_zap2it_id(id,
|
11
|
-
get('GetSeriesByRemoteID.php').params(zap2it: id
|
10
|
+
def get_series_by_zap2it_id(id, options = {})
|
11
|
+
get('GetSeriesByRemoteID.php').params({ zap2it: id }.merge(options)).response
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
get('GetEpisodeByAirDate.php').params(seriesid: series_id, airdate: air_date
|
14
|
+
def get_episode(series_id, air_date, options = {})
|
15
|
+
get('GetEpisodeByAirDate.php').params({ seriesid: series_id, airdate: air_date }.merge(options)).response
|
16
16
|
end
|
17
17
|
end
|
data/lib/thetvdb_api/series.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class ThetvdbApi::Series < ThetvdbApi::Base
|
2
|
-
def find(series_id,
|
3
|
-
get("#{series_uri}/{language}.xml").params(series_id: series_id
|
2
|
+
def find(series_id, options = {})
|
3
|
+
get("#{series_uri}/{language}.xml").params({ series_id: series_id }.merge(options)).response
|
4
4
|
end
|
5
5
|
|
6
|
-
def find_full(series_id,
|
7
|
-
get("#{series_uri}/all/{language}.xml").params(series_id: series_id
|
6
|
+
def find_full(series_id, options = {})
|
7
|
+
get("#{series_uri}/all/{language}.xml").params({ series_id: series_id }.merge(options)).response
|
8
8
|
end
|
9
9
|
end
|
data/lib/thetvdb_api/update.rb
CHANGED
@@ -1,17 +1,51 @@
|
|
1
1
|
class ThetvdbApi::Update < ThetvdbApi::Base
|
2
|
-
def day
|
3
|
-
get(
|
2
|
+
def day(options = {})
|
3
|
+
get(day_path).params(options).response
|
4
4
|
end
|
5
5
|
|
6
|
-
def
|
7
|
-
get(
|
6
|
+
def day_url
|
7
|
+
get(day_path).url
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
get(
|
10
|
+
def week(options = {})
|
11
|
+
get(week_path).params(options).response
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
get(
|
14
|
+
def week_url
|
15
|
+
get(week_path).url
|
16
|
+
end
|
17
|
+
|
18
|
+
def month(options = {})
|
19
|
+
get(month_path).params(options).response
|
20
|
+
end
|
21
|
+
|
22
|
+
def month_url
|
23
|
+
get(month_path).url
|
24
|
+
end
|
25
|
+
|
26
|
+
def all(options = {})
|
27
|
+
get(all_path).params(options).response
|
28
|
+
end
|
29
|
+
|
30
|
+
def all_url
|
31
|
+
get(all_path).url
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def day_path
|
37
|
+
'{api_key}/updates/updates_day.xml'
|
38
|
+
end
|
39
|
+
|
40
|
+
def week_path
|
41
|
+
'{api_key}/updates/updates_week.xml'
|
42
|
+
end
|
43
|
+
|
44
|
+
def month_path
|
45
|
+
'{api_key}/updates/updates_month.xml'
|
46
|
+
end
|
47
|
+
|
48
|
+
def all_path
|
49
|
+
'{api_key}/updates/updates_all.xml'
|
16
50
|
end
|
17
51
|
end
|
data/lib/thetvdb_api/version.rb
CHANGED
@@ -7,25 +7,25 @@ describe ThetvdbApi::Client do
|
|
7
7
|
describe '.search' do
|
8
8
|
describe '.get_series' do
|
9
9
|
it 'should return response class' do
|
10
|
-
client.search.get_series('buffy').class.should ==
|
10
|
+
client.search.get_series('buffy').class.should == ThetvdbApi::Response
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '.get_series_by_imdb_id' do
|
15
15
|
it 'should return response class' do
|
16
|
-
client.search.get_series_by_imdb_id('tt0118276').class.should ==
|
16
|
+
client.search.get_series_by_imdb_id('tt0118276').class.should == ThetvdbApi::Response
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '.get_series_by_zap2it_id' do
|
21
21
|
it 'should return response class' do
|
22
|
-
client.search.get_series_by_zap2it_id('EP00213110').class.should ==
|
22
|
+
client.search.get_series_by_zap2it_id('EP00213110').class.should == ThetvdbApi::Response
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe '.
|
26
|
+
describe '.get_episode' do
|
27
27
|
it 'should return response class' do
|
28
|
-
client.search.
|
28
|
+
client.search.get_episode('70327','1997-03-10').class.should == ThetvdbApi::Response
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -33,13 +33,13 @@ describe ThetvdbApi::Client do
|
|
33
33
|
describe '.series' do
|
34
34
|
describe '.find' do
|
35
35
|
it 'should return response class' do
|
36
|
-
client.series.find('70327').class.should ==
|
36
|
+
client.series.find('70327').class.should == ThetvdbApi::Response
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '.find_full' do
|
41
41
|
it 'should return response class' do
|
42
|
-
client.series.find_full('70327').class.should ==
|
42
|
+
client.series.find_full('70327').class.should == ThetvdbApi::Response
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -47,7 +47,7 @@ describe ThetvdbApi::Client do
|
|
47
47
|
describe '.actor' do
|
48
48
|
describe '.find' do
|
49
49
|
it 'should return response class' do
|
50
|
-
client.actor.find('70327').class.should ==
|
50
|
+
client.actor.find('70327').class.should == ThetvdbApi::Response
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -55,7 +55,7 @@ describe ThetvdbApi::Client do
|
|
55
55
|
describe '.banner' do
|
56
56
|
describe '.find' do
|
57
57
|
it 'should return response class' do
|
58
|
-
client.banner.find('70327').class.should ==
|
58
|
+
client.banner.find('70327').class.should == ThetvdbApi::Response
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -63,25 +63,25 @@ describe ThetvdbApi::Client do
|
|
63
63
|
describe '.episode' do
|
64
64
|
describe '.find_by_default_order' do
|
65
65
|
it 'should return response class' do
|
66
|
-
client.episode.find_by_default_order('70327', '1', '1').class.should ==
|
66
|
+
client.episode.find_by_default_order('70327', '1', '1').class.should == ThetvdbApi::Response
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe '.find_by_dvd_order' do
|
71
71
|
it 'should return response class' do
|
72
|
-
client.episode.find_by_dvd_order('70327', '1', '1').class.should ==
|
72
|
+
client.episode.find_by_dvd_order('70327', '1', '1').class.should == ThetvdbApi::Response
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
describe '.find_by_absolute_order' do
|
77
77
|
it 'should return response class' do
|
78
|
-
client.episode.find_by_absolute_order('70327', '1').class.should ==
|
78
|
+
client.episode.find_by_absolute_order('70327', '1').class.should == ThetvdbApi::Response
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
describe '.find' do
|
83
83
|
it 'should return response class' do
|
84
|
-
client.episode.find('533011').class.should ==
|
84
|
+
client.episode.find('533011').class.should == ThetvdbApi::Response
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -89,19 +89,19 @@ describe ThetvdbApi::Client do
|
|
89
89
|
describe '.update' do
|
90
90
|
describe '.day' do
|
91
91
|
it 'should return response class' do
|
92
|
-
client.update.day.class.should ==
|
92
|
+
client.update.day.class.should == ThetvdbApi::Response
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
describe '.week' do
|
97
97
|
it 'should return response class' do
|
98
|
-
client.update.week.class.should ==
|
98
|
+
client.update.week.class.should == ThetvdbApi::Response
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe '.month' do
|
103
103
|
it 'should return response class' do
|
104
|
-
client.update.month.class.should ==
|
104
|
+
client.update.month.class.should == ThetvdbApi::Response
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -6,25 +6,25 @@ describe ThetvdbApi::Episode do
|
|
6
6
|
describe 'real request' do
|
7
7
|
describe '.find_by_default_order' do
|
8
8
|
it 'should return response class' do
|
9
|
-
model.find_by_default_order('70327', '1', '1').class.should ==
|
9
|
+
model.find_by_default_order('70327', '1', '1').class.should == ThetvdbApi::Response
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '.find_by_dvd_order' do
|
14
14
|
it 'should return response class' do
|
15
|
-
model.find_by_dvd_order('70327', '1', '1').class.should ==
|
15
|
+
model.find_by_dvd_order('70327', '1', '1').class.should == ThetvdbApi::Response
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '.find_by_absolute_order' do
|
20
20
|
it 'should return response class' do
|
21
|
-
model.find_by_absolute_order('70327', '1').class.should ==
|
21
|
+
model.find_by_absolute_order('70327', '1').class.should == ThetvdbApi::Response
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '.find' do
|
26
26
|
it 'should return response class' do
|
27
|
-
model.find('533011').class.should ==
|
27
|
+
model.find('533011').class.should == ThetvdbApi::Response
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -6,25 +6,25 @@ describe ThetvdbApi::Search do
|
|
6
6
|
describe 'real request' do
|
7
7
|
describe '.get_series' do
|
8
8
|
it 'should return response class' do
|
9
|
-
model.get_series('buffy').class.should ==
|
9
|
+
model.get_series('buffy').class.should == ThetvdbApi::Response
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '.get_series_by_imdb_id' do
|
14
14
|
it 'should return response class' do
|
15
|
-
model.get_series_by_imdb_id('tt0118276').class.should ==
|
15
|
+
model.get_series_by_imdb_id('tt0118276').class.should == ThetvdbApi::Response
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '.get_series_by_zap2it_id' do
|
20
20
|
it 'should return response class' do
|
21
|
-
model.get_series_by_zap2it_id('EP00213110').class.should ==
|
21
|
+
model.get_series_by_zap2it_id('EP00213110').class.should == ThetvdbApi::Response
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe '.
|
25
|
+
describe '.get_episode' do
|
26
26
|
it 'should return response class' do
|
27
|
-
model.
|
27
|
+
model.get_episode('70327', '1997-03-10').class.should == ThetvdbApi::Response
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -6,13 +6,13 @@ describe ThetvdbApi::Series do
|
|
6
6
|
describe 'real request' do
|
7
7
|
describe '.find' do
|
8
8
|
it 'should return response class' do
|
9
|
-
model.find('70327').class.should ==
|
9
|
+
model.find('70327').class.should == ThetvdbApi::Response
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '.find_full' do
|
14
14
|
it 'should return response class' do
|
15
|
-
model.find_full('70327').class.should ==
|
15
|
+
model.find_full('70327').class.should == ThetvdbApi::Response
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -6,20 +6,26 @@ describe ThetvdbApi::Update do
|
|
6
6
|
describe 'real request' do
|
7
7
|
describe '.day' do
|
8
8
|
it 'should return response class' do
|
9
|
-
model.day.class.should ==
|
9
|
+
model.day.class.should == ThetvdbApi::Response
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '.week' do
|
14
14
|
it 'should return response class' do
|
15
|
-
model.week.class.should ==
|
15
|
+
model.week.class.should == ThetvdbApi::Response
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '.month' do
|
20
20
|
it 'should return response class' do
|
21
|
-
model.month.class.should ==
|
21
|
+
model.month.class.should == ThetvdbApi::Response
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.all' do
|
26
|
+
it 'should return response class' do
|
27
|
+
model.all.class.should == ThetvdbApi::Response
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
25
|
-
end
|
31
|
+
end
|