tvdb_party 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/tvdb_party/search.rb +8 -6
- data/test/tvdb_party_test.rb +18 -1
- data/tvdb_party.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/tvdb_party/search.rb
CHANGED
@@ -2,16 +2,18 @@ module TvdbParty
|
|
2
2
|
class Search
|
3
3
|
include HTTParty
|
4
4
|
include HTTParty::Icebox
|
5
|
+
attr_accessor :language
|
5
6
|
cache :store => 'file', :timeout => 120, :location => Dir.tmpdir
|
6
7
|
|
7
8
|
base_uri 'www.thetvdb.com/api'
|
8
9
|
|
9
|
-
def initialize(the_api_key)
|
10
|
+
def initialize(the_api_key, language = 'en')
|
10
11
|
@api_key = the_api_key
|
12
|
+
@language = language
|
11
13
|
end
|
12
14
|
|
13
15
|
def search(series_name)
|
14
|
-
response = self.class.get("/GetSeries.php", {:query => {:seriesname => series_name}})
|
16
|
+
response = self.class.get("/GetSeries.php", {:query => {:seriesname => series_name, :language => @language}})
|
15
17
|
return [] unless response["Data"]
|
16
18
|
|
17
19
|
case response["Data"]["Series"]
|
@@ -24,8 +26,8 @@ module TvdbParty
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
def get_series_by_id(series_id)
|
28
|
-
response = self.class.get("/#{@api_key}/series/#{series_id}
|
29
|
+
def get_series_by_id(series_id, language = self.language)
|
30
|
+
response = self.class.get("/#{@api_key}/series/#{series_id}/#{language}.xml")
|
29
31
|
if response["Data"] && response["Data"]["Series"]
|
30
32
|
Series.new(self, response["Data"]["Series"])
|
31
33
|
else
|
@@ -33,8 +35,8 @@ module TvdbParty
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
|
-
def get_episode(series, season_number, episode_number)
|
37
|
-
response = self.class.get("/#{@api_key}/series/#{series.id}/default/#{season_number}/#{episode_number}
|
38
|
+
def get_episode(series, season_number, episode_number, language = self.language)
|
39
|
+
response = self.class.get("/#{@api_key}/series/#{series.id}/default/#{season_number}/#{episode_number}/#{language}.xml")
|
38
40
|
if response["Data"] && response["Data"]["Episode"]
|
39
41
|
Episode.new(response["Data"]["Episode"])
|
40
42
|
else
|
data/test/tvdb_party_test.rb
CHANGED
@@ -34,10 +34,27 @@ class TvdbPartyTest < Test::Unit::TestCase
|
|
34
34
|
should "have a series" do
|
35
35
|
assert_equal TvdbParty::Series, @series.class
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
|
+
should "have a first episode" do
|
39
|
+
assert_equal "110413", @series.get_episode(1, 1).id
|
40
|
+
end
|
38
41
|
end
|
39
42
|
|
40
43
|
end
|
41
44
|
|
42
45
|
end
|
46
|
+
context "non english series" do
|
47
|
+
setup do
|
48
|
+
@tvdb = TvdbParty::Search.new('A97A9243F8030477', 'de')
|
49
|
+
end
|
50
|
+
context "search for real show" do
|
51
|
+
setup do
|
52
|
+
@results = @tvdb.search("Keine Gnade für Dad")
|
53
|
+
end
|
54
|
+
|
55
|
+
should "have 1 results" do
|
56
|
+
assert_equal 1, @results.size
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
43
60
|
end
|
data/tvdb_party.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tvdb_party}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jon Maddox"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-01-02}
|
13
13
|
s.description = %q{Simple Ruby library to talk to thetvdb.com's api}
|
14
14
|
s.email = %q{jon@mustacheinc.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tvdb_party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Maddox
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-02 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|