thetvdb_party 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cf3bf1a43c2e0027e04bf9434f8fb69c9178d66
4
- data.tar.gz: 0265a264153e58967a68f17efeb828be92fdf904
3
+ metadata.gz: fe3a4f17f547c861e87303b8fa3be45e8c6e1a7b
4
+ data.tar.gz: ae9d09780aa198bf2733df4668e727996b147dab
5
5
  SHA512:
6
- metadata.gz: fa90db343f77b61d7b28904797d2b32c0dd0e4431d6afaa84a21acbd08e2cea505667884c8fd14c45bdd6262f2017959d6e0fc062d70f9bf4954d5ac92351400
7
- data.tar.gz: 69df7b8cdc293b60367a97d5ca98897f10eb7da5ad7c463665ca7c6baf338123537e83ccfcc4fd456db926caac4e95725f1b6e23f70d2dc51c09dbaaef9cb6cd
6
+ metadata.gz: 5e329d481bc61bd2b5387981f7036ff0b641018970cbb85a9f980ccec6dfad4b1f19060917f0e6c493cb4e0d499faf225434feaa6e0a0731f0840d5d22a4e518
7
+ data.tar.gz: 2279f2ac4c555f214384278e363b82ee310805208a16144d3b218bbf176c295628a85c26d86b3fd2c86e4a75249cf754431fe0ae4fc4a860749ce7ba3e5aa71c
@@ -12,32 +12,34 @@ module TheTvDbParty
12
12
 
13
13
  private
14
14
  def unzip_file(zip_buffer)
15
- @actors = []
16
- @banners = []
17
-
18
15
  zip_file = Zip::InputStream.open(StringIO.new(zip_buffer))
19
16
 
20
17
  while entry = zip_file.get_next_entry
21
18
  case entry.name
22
- when "en.xml"
23
- full_hash = MultiXml.parse(entry.get_input_stream.read)
24
- @full_series_record = FullSeriesRecord.new(@client, full_hash["Data"])
25
19
  when "actors.xml"
26
20
  actors_hash = MultiXml.parse(entry.get_input_stream.read)
27
21
 
28
- actors_hash["Actors"]["Actor"].each do |a|
29
- actors << Actor.new(@client, a)
30
- end if actors_hash["Actors"]
22
+ case actors_hash["Actors"]["Actor"]
23
+ when Array
24
+ @actors = actors_hash["Actors"]["Actor"].map { |a| Actor.new(self, a) }
25
+ when Hash
26
+ @actors = [Actor.new(self, actors_hash["Actors"]["Actor"])]
27
+ else
28
+ @actors = []
29
+ end if actors_hash && actors_hash["Actors"]
31
30
  when "banners.xml"
32
31
  banners_hash = MultiXml.parse(entry.get_input_stream.read)
33
32
  case banners_hash["Banners"]["Banner"]
34
33
  when Array
35
- banners_hash["Banners"]["Banner"].map {|s|Banner.new(self, s)}
34
+ @banners = banners_hash["Banners"]["Banner"].map { |b| Banner.new(self, b) }
36
35
  when Hash
37
- [Banner.new(self, banners_hash["Banners"]["Banner"])]
36
+ @banners = [Banner.new(self, banners_hash["Banners"]["Banner"])]
38
37
  else
39
- []
40
- end if banners_hash
38
+ @banners = []
39
+ end if banners_hash && banners_hash["Banners"]
40
+ else
41
+ full_hash = MultiXml.parse(entry.get_input_stream.read)
42
+ @full_series_record = FullSeriesRecord.new(@client, full_hash["Data"])
41
43
  end
42
44
  end
43
45
  end
@@ -112,7 +112,8 @@ module TheTvDbParty
112
112
  # See Also:: #get_series_season_episode, #get_series_absolute_episode, #get_base_episode_record
113
113
  def get_series_dvd_season_episode(seriesid, season_number, episode_number)
114
114
  unless @language
115
- request_url = "#{@apikey}/series/#{seriesid}/dvd/#{season_number}/#{episode_number}"
115
+ # DVD requires you to specify language:
116
+ request_url = "#{@apikey}/series/#{seriesid}/dvd/#{season_number}/#{episode_number}/en.xml"
116
117
  else
117
118
  request_url = "#{@apikey}/series/#{seriesid}/dvd/#{season_number}/#{episode_number}/#{@language}.xml"
118
119
  end
@@ -129,7 +130,8 @@ module TheTvDbParty
129
130
  # See Also:: #get_series_season_episode, #get_series_dvd_season_episode, #get_base_episode_record
130
131
  def get_series_absolute_episode(seriesid, episode_number)
131
132
  unless @language
132
- request_url = "#{@apikey}/series/#{seriesid}/absolute/#{episode_number}"
133
+ # Absolute requires you to specify language:
134
+ request_url = "#{@apikey}/series/#{seriesid}/absolute/#{episode_number}/en.xml"
133
135
  else
134
136
  request_url = "#{@apikey}/series/#{seriesid}/absolute/#{episode_number}/#{@language}.xml"
135
137
  end
@@ -1,4 +1,4 @@
1
1
  module TheTvDbParty
2
2
  # The current version of the *thetvdb_party* gem
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
@@ -0,0 +1,104 @@
1
+ require 'rspec'
2
+ require 'thetvdb_party'
3
+
4
+ describe 'TheTvDbParty::Update' do
5
+ it 'should have a client associated with it' do
6
+ client = TheTvDbParty::Client.new(nil)
7
+ record = TheTvDbParty::Update.new(client, { },false)
8
+ expect(record.client).to be_an_instance_of(TheTvDbParty::Client)
9
+ end
10
+
11
+ it 'should have a nil client if constructed with nil' do
12
+ record = TheTvDbParty::Update.new(nil, { },false)
13
+ expect(record.client).to be_nil
14
+ end
15
+
16
+ it 'should read timestamp when passed hashed XML with timestamp (last timestamp format)' do
17
+ record = TheTvDbParty::Update.new(nil,{"Items"=>{"Time"=>"1432052332"}},false)
18
+ expect(record.timestamp).to_not be_nil
19
+ expect(record.timestamp).to eq("1432052332")
20
+ end
21
+ it 'should read series when passed hashed XML with series data (last timestamp format)' do
22
+ record = TheTvDbParty::Update.new(nil,{"Items"=>{"Series"=>["123","234","345"]}},false)
23
+ expect(record.series).to_not be_nil
24
+ expect(record.series).to match_array([{:seriesid=>"123",:updatetime=>nil},{:seriesid=>"234",:updatetime=>nil},{:seriesid=>"345",:updatetime=>nil}])
25
+ end
26
+ it 'should read episodes when passed hashed XML with series data (last timestamp format)' do
27
+ record = TheTvDbParty::Update.new(nil,{"Items"=>{"Episode"=>["123","234","345"]}},false)
28
+ expect(record.episodes).to_not be_nil
29
+ expect(record.episodes).to match_array([{:episodeid=>"123",:seriesid=>nil,:updatetime=>nil},{:episodeid=>"234",:seriesid=>nil,:updatetime=>nil},{:episodeid=>"345",:seriesid=>nil,:updatetime=>nil}])
30
+ end
31
+ it 'should not have data not passed in (last timestamp format)' do
32
+ record = TheTvDbParty::Update.new(nil,{"Items"=>{"Episode"=>["123","234","345"]}},false)
33
+ expect(record.series).to be_nil
34
+ expect(record.timestamp).to be_nil
35
+ expect(record.banners).to be_nil
36
+ record = TheTvDbParty::Update.new(nil,{"Items"=>{"Series"=>["123","234","345"]}},false)
37
+ expect(record.episodes).to be_nil
38
+ expect(record.timestamp).to be_nil
39
+ expect(record.banners).to be_nil
40
+ record = TheTvDbParty::Update.new(nil,{"Items"=>{"Time"=>"1432052332"}},false)
41
+ expect(record.episodes).to be_nil
42
+ expect(record.series).to be_nil
43
+ expect(record.banners).to be_nil
44
+ end
45
+ it 'should read timestamp when passed hashed XML with timestamp (timeframe format)' do
46
+ data = {"Data"=>{"time"=>"1432053001"}}
47
+ record = TheTvDbParty::Update.new(nil,data,false)
48
+ expect(record.timestamp).to_not be_nil
49
+ expect(record.timestamp).to eq("1432053001")
50
+ end
51
+ it 'should read series when passed hashed XML with timestamp (timeframe format)' do
52
+ data = {"Data"=>{"Series"=>[{"id"=>"70328", "time"=>"1431972440"}, {"id"=>"70383", "time"=>"1431973145"}]}}
53
+ record = TheTvDbParty::Update.new(nil,data,false)
54
+ expect(record.series).to_not be_nil
55
+ expect(record.series).to match_array([{:seriesid=>"70328",:updatetime=>"1431972440"},{:seriesid=>"70383",:updatetime=>"1431973145"}])
56
+ end
57
+ it 'should read episodes when passed hashed XML with timestamp (timeframe format)' do
58
+ data = {"Data"=>{"Episode"=>[{"id"=>"5229051", "Series"=>"295317", "time"=>"1431966617"}, {"id"=>"5229389", "Series"=>"285520", "time"=>"1431966652"}]}}
59
+ record = TheTvDbParty::Update.new(nil,data,false)
60
+ expect(record.episodes).to_not be_nil
61
+ expect(record.episodes).to match_array([{:episodeid=>"5229051",:seriesid=>"295317",:updatetime=>"1431966617"},{:episodeid=>"5229389",:seriesid=>"285520",:updatetime=>"1431966652"}])
62
+ end
63
+ it 'should read banners when passed hashed XML with timestamp (timeframe format)' do
64
+ data = {"Data"=>{"Banner"=>[{"SeasonNum"=>"1", "Series"=>"253534", "format"=>"standard", "language"=>"nl", "path"=>"seasons/253534-1-3.jpg", "time"=>"1431987040", "type"=>"season"}, {"Series"=>"294169", "format"=>"1920x1080", "path"=>"fanart/original/294169-4.jpg", "time"=>"1431987428", "type"=>"fanart"}]}}
65
+ record = TheTvDbParty::Update.new(nil,data,false)
66
+ expect(record.banners).to_not be_nil
67
+ expect(record.banners).to match_array([{:path=>"seasons/253534-1-3.jpg",:format=>"standard",:type=>"season",:seriesid=>"253534",:seasonnum=>"1",:language=>"nl",:updatetime=>"1431987040"},
68
+ {:path=>"fanart/original/294169-4.jpg",:format=>"1920x1080",:type=>"fanart",:seriesid=>"294169",:seasonnum=>nil,:language=>nil,:updatetime=>"1431987428"}])
69
+ end
70
+ it 'should not have data not passed in (timeframe format)' do
71
+ data = {"Data"=>{"time"=>"1432053001"}}
72
+ record = TheTvDbParty::Update.new(nil,data,false)
73
+ expect(record.episodes).to be_nil
74
+ expect(record.series).to be_nil
75
+ expect(record.banners).to be_nil
76
+ data = {"Data"=>{"Series"=>[{"id"=>"70328", "time"=>"1431972440"}, {"id"=>"70383", "time"=>"1431973145"}]}}
77
+ record = TheTvDbParty::Update.new(nil,data,false)
78
+ expect(record.episodes).to be_nil
79
+ expect(record.timestamp).to be_nil
80
+ expect(record.banners).to be_nil
81
+ data = {"Data"=>{"Episode"=>[{"id"=>"5229051", "Series"=>"295317", "time"=>"1431966617"}, {"id"=>"5229389", "Series"=>"285520", "time"=>"1431966652"}]}}
82
+ record = TheTvDbParty::Update.new(nil,data,false)
83
+ expect(record.series).to be_nil
84
+ expect(record.timestamp).to be_nil
85
+ expect(record.banners).to be_nil
86
+ data = {"Data"=>{"Banner"=>[{"SeasonNum"=>"1", "Series"=>"253534", "format"=>"standard", "language"=>"nl", "path"=>"seasons/253534-1-3.jpg", "time"=>"1431987040", "type"=>"season"}, {"Series"=>"294169", "format"=>"1920x1080", "path"=>"fanart/original/294169-4.jpg", "time"=>"1431987428", "type"=>"fanart"}]}}
87
+ record = TheTvDbParty::Update.new(nil,data,false)
88
+ expect(record.series).to be_nil
89
+ expect(record.timestamp).to be_nil
90
+ expect(record.episodes).to be_nil
91
+ end
92
+ ### Unable to get Zipping to work in this test
93
+ #it 'should read zipped data' do
94
+ # Zip::ZipOutputStream::open("my.zip") {
95
+ # |io|
96
+ #
97
+ # io.put_next_entry("first_entry.txt")
98
+ # io.write "Hello world!"
99
+ #
100
+ # io.put_next_entry("adir/first_entry.txt")
101
+ # io.write "Hello again!"
102
+ #}
103
+ #end
104
+ end
@@ -1,6 +1,7 @@
1
1
  require 'rspec'
2
2
  require 'thetvdb_party'
3
3
 
4
+
4
5
  describe 'TheTvDbParty' do
5
6
  it 'should find search results' do
6
7
  client = TheTvDbParty::Client.new(ENV["TVDB_API_KEY"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thetvdb_party
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fredrik Høisæther Rasch
@@ -137,6 +137,7 @@ files:
137
137
  - spec/thetvdb_party/client_spec.rb
138
138
  - spec/thetvdb_party/fullseriesrecord_spec.rb
139
139
  - spec/thetvdb_party/searchseriesrecord_spec.rb
140
+ - spec/thetvdb_party/update_spec.rb
140
141
  - spec/thetvdb_party_spec.rb
141
142
  - thetvdb_party.gemspec
142
143
  homepage: https://github.com/couven92/thetvdb_party
@@ -178,5 +179,6 @@ test_files:
178
179
  - spec/thetvdb_party/client_spec.rb
179
180
  - spec/thetvdb_party/fullseriesrecord_spec.rb
180
181
  - spec/thetvdb_party/searchseriesrecord_spec.rb
182
+ - spec/thetvdb_party/update_spec.rb
181
183
  - spec/thetvdb_party_spec.rb
182
184
  has_rdoc: