thetvdb_party 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/thetvdb_party.rb +1 -0
- data/lib/thetvdb_party/client.rb +25 -0
- data/lib/thetvdb_party/update.rb +87 -0
- data/lib/thetvdb_party/version.rb +1 -1
- data/spec/thetvdb_party_spec.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee53cdd57282197c55fe841acf70b56629dd6f05
|
4
|
+
data.tar.gz: 7fdf05575e8d53777c43f85188f41da6d6d21b12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07914eff8fc00f9b6543fa24cb66d82a336c9c441161f25a11f7c3d37cf901261ce8c3733f000da95f2710866ac5f9c2727bb82a12a08522aba80173465d3f61
|
7
|
+
data.tar.gz: 0c0170c371bfbc89c7fd9596ec76e7015c93c48387bf118012bad3d6237950369bb4fe198db97e7aceed2a23b0ee9e42064f591fc33cd3213c6309c138c1604e
|
data/lib/thetvdb_party.rb
CHANGED
data/lib/thetvdb_party/client.rb
CHANGED
@@ -207,6 +207,31 @@ module TheTvDbParty
|
|
207
207
|
|
208
208
|
FullSeriesRecord.new self, resp["Data"]
|
209
209
|
end
|
210
|
+
|
211
|
+
def get_updates_by_timeframe(timeframe)
|
212
|
+
if(["day","week","month","all"].index(timeframe).nil? == false)
|
213
|
+
request_url = "#{@apikey}/updates/updates_#{timeframe}.zip"
|
214
|
+
request_url = URI.join(BASE_URL,'api/', request_url)
|
215
|
+
|
216
|
+
resp = self.class.get(request_url)
|
217
|
+
return nil unless resp.nil? == false
|
218
|
+
return nil unless resp.body.nil? == false
|
219
|
+
return Update.new(self,resp.body,true)
|
220
|
+
else
|
221
|
+
return nil
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def get_updates_by_lastupdate(timestamp, type = "series")
|
226
|
+
if(["series","episode","all","none"].index(type).nil? == false)
|
227
|
+
request_url = "Updates.php?time=#{timestamp}&type=#{type}"
|
228
|
+
request_url = URI.join(BASE_URL,'api/',request_url)
|
229
|
+
|
230
|
+
resp = self.class.get(request_url)
|
231
|
+
return nil unless resp.nil? == false
|
232
|
+
return Update.new(self,resp,false)
|
233
|
+
end
|
234
|
+
end
|
210
235
|
|
211
236
|
private
|
212
237
|
def get_base_episode_record_from_url(request_url)
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module TheTvDbParty
|
2
|
+
# TheTvDB updates
|
3
|
+
|
4
|
+
#Struct.new("SerieUpdate",:seriesid,:updatetime)
|
5
|
+
#Struct.new("EpisodeUpdate",:episodeid,:seriesid,:updatetime)
|
6
|
+
#Struct.new("BannerUpdate",:path,:format,:type,:seriesid,:seasonnum,:language)
|
7
|
+
|
8
|
+
class Update
|
9
|
+
# TheTvDB client used
|
10
|
+
attr_reader :client
|
11
|
+
# The timestamp from TheTvDB when the update was handled. To be used for update chaining and verificaton.
|
12
|
+
attr_reader :timestamp
|
13
|
+
# The list of seriesids for shows which has been updated
|
14
|
+
attr_reader :series
|
15
|
+
# The list of episodeids for episodes which has been updated
|
16
|
+
attr_reader :episodes
|
17
|
+
# The list of bannerids for banners which has been updated
|
18
|
+
attr_reader :banners
|
19
|
+
|
20
|
+
def initialize(client, data, ziped)
|
21
|
+
@client = client
|
22
|
+
|
23
|
+
if(ziped==true)
|
24
|
+
read_ziped_values(data)
|
25
|
+
else
|
26
|
+
read_hash_values(data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def read_ziped_values(zip_buffer)
|
32
|
+
zip_file = Zip::InputStream.open(StringIO.new(zip_buffer))
|
33
|
+
|
34
|
+
# The zip files only consists of a single file
|
35
|
+
entry = zip_file.get_next_entry
|
36
|
+
full_hash = MultiXml.parse(entry.get_input_stream.read)
|
37
|
+
read_hash_values(full_hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
def read_hash_values(hash)
|
41
|
+
if hash["Data"]
|
42
|
+
data = hash["Data"]
|
43
|
+
@timestamp = data["time"] #Change to Time.new(data["time"])?
|
44
|
+
if(data["Series"])
|
45
|
+
@series = Array.new
|
46
|
+
for serie in data["Series"]
|
47
|
+
#@series.push(Struct::SerieUpdate.new(serie["id"],serie["time"]))
|
48
|
+
@series.push({:seriesid=>serie["id"],:updatetime=>serie["time"]})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
if(data["Episode"])
|
52
|
+
@episodes = Array.new
|
53
|
+
for episode in data["Episode"]
|
54
|
+
#@episodes.push(Struct::EpisodeUpdate.new(episode["id"],episode["Series"],episode["time"]))
|
55
|
+
@episodes.push({:episodeid=>episode["id"],:seriesid=>episode["Series"],:updatetime=>serie["time"]})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
if(data["Banner"])
|
59
|
+
@banners = Array.new
|
60
|
+
for banner in data["Banner"]
|
61
|
+
#@banners.push(Struct::BannerUpdate.new(banner["path"],banner["format"],banner["type"],banner["Series"],banner["SeasonNum"],banner["language"],banner["time"]))
|
62
|
+
@banners.push({:path=>banner["path"],:format=>banner["format"],:type=>banner["type"],:seriesid=>banner["Series"],:seasonnum=>banner["SeasonNum"],:language=>banner["language"],:updatetime=>banner["time"]})
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
if hash["Items"]
|
67
|
+
items = hash["Items"]
|
68
|
+
@timestamp = items["Time"]
|
69
|
+
if items["Series"]
|
70
|
+
@series = Array.new
|
71
|
+
for serie in items["Series"]
|
72
|
+
#@series.push(Struct::SerieUpdate.new(serie,nil))
|
73
|
+
@series.push({:seriesid=>serie,:updatetime=>nil})
|
74
|
+
end
|
75
|
+
end
|
76
|
+
if items["Episode"]
|
77
|
+
@episodes = Array.new
|
78
|
+
for episode in items["Episode"]
|
79
|
+
#@episodes.push(Struct::EpisodeUpdate.new(episode,nil,nil))
|
80
|
+
@episodes.push({:episodeid=>episode,:seriesid=>nil,:updatetime=>nil})
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
data/spec/thetvdb_party_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe 'TheTvDbParty' do
|
|
11
11
|
|
12
12
|
it 'should find the Base Series Record for search results' do
|
13
13
|
client = TheTvDbParty::Client.new(ENV["TVDB_API_KEY"])
|
14
|
-
pending "No API key available, test cannot run. Configure .env file to include an api key." unless client.apikey
|
14
|
+
pending "No API key available, test cannot run. Configure .env.yml file to include an api key." unless client.apikey
|
15
15
|
client.search("The Mentalist").each do |result_record|
|
16
16
|
expect(result_record).to be_a TheTvDbParty::SearchSeriesRecord
|
17
17
|
base_series_record = result_record.get_base_series_record
|
@@ -22,7 +22,7 @@ describe 'TheTvDbParty' do
|
|
22
22
|
|
23
23
|
it 'should find the Full Series Record for search results and this should include an episode list' do
|
24
24
|
client = TheTvDbParty::Client.new(ENV["TVDB_API_KEY"])
|
25
|
-
pending "No API key available, test cannot run. Configure .env file to include an api key." unless client.apikey
|
25
|
+
pending "No API key available, test cannot run. Configure .env.yml file to include an api key." unless client.apikey
|
26
26
|
client.search("The Mentalist").each do |result_record|
|
27
27
|
expect(result_record).to be_a TheTvDbParty::SearchSeriesRecord
|
28
28
|
full_series_record = result_record.get_full_series_record
|
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
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fredrik Høisæther Rasch
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-
|
15
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/thetvdb_party/client.rb
|
127
127
|
- lib/thetvdb_party/fullseriesrecord.rb
|
128
128
|
- lib/thetvdb_party/searchseriesrecord.rb
|
129
|
+
- lib/thetvdb_party/update.rb
|
129
130
|
- lib/thetvdb_party/version.rb
|
130
131
|
- spec/spec_helper.rb
|
131
132
|
- spec/thetvdb_party/actor_spec.rb
|