tvdbjson 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f31635d50ebac2a73984a6a67ff90ada68e1e64
4
- data.tar.gz: 556dad6d367076be42d09893689777e9a2363938
3
+ metadata.gz: c8d402112883f10ef7fde9d3f7b3b2094f511253
4
+ data.tar.gz: 59bdbe4dab687f6c6fcff256d7d331dcd6d7fa3c
5
5
  SHA512:
6
- metadata.gz: c278a1a3ad4341da93bb431bd87c328d61e4ead7fb5470f85ca417b32076b02e1a444289e55d5476158ae31cc173dd9c34c935d5faff2a61a50d4b5d7adaa509
7
- data.tar.gz: e7b45149f67cc04141adc869c572bd81c78f382ce6c325861cc5df17433040e8f1507a36fba54de38983a5d319faff2bf77dd3da236cb4ba76d04f353703f2f0
6
+ metadata.gz: 69585683eef478df42459d47ac9cc667d88e93a52e3463e658aa1ff0b17a1b99e24eda0d193a16c2c2a50d4edda7e721554148a75efd562ca0b83e7d148d7dcc
7
+ data.tar.gz: 740017e3bdd296f850a130820ed1193a974d626a05513e7806ce48b7f62624cbb15257aa58baead652b5cc6a8024bc08a4241832c7b79aee43a83714fc88b7b8
data/README.md CHANGED
@@ -5,7 +5,7 @@ A super-unofficial Ruby Gem for thetvdb.com ['swagger' api](https://api.thetvdb.
5
5
 
6
6
  ### Install the gem
7
7
 
8
- Visit [rubygems](https://rubygems.org/gems/thetvdbjson) for instructions on how to install this gem via the command line, or for how to include it in your gemfile.
8
+ Visit [rubygems](https://rubygems.org/gems/tvdbjson) for instructions on how to install this gem via the command line, or for how to include it in your gemfile.
9
9
 
10
10
  ### Create some environment variables
11
11
  [Create an account](https://www.thetvdb.com/?tab=register) and [register for your API Key](https://www.thetvdb.com/?tab=apiregister) on thetvdb.com
@@ -66,6 +66,7 @@ You're going to need to read the source for full details, as this gem is a work
66
66
  search_options = { :series_id => game_of_thrones.id, :type => "season", :subkey => 5 }
67
67
  image_results = Tvdbjson::Image.search_by_series_and_season(search_options, auth)
68
68
 
69
+ # Or graphical fanart of a Television series (the other option being text)
69
70
  search_options = { :series_id => game_of_thrones.id, :type => "fanart", :subkey => "graphical" }
70
71
  image_results = Tvdbjson::Image.search_by_series_and_season(search_options, auth)
71
72
 
@@ -73,6 +74,10 @@ You're going to need to read the source for full details, as this gem is a work
73
74
  search_query = { :series_id => game_of_thrones.id, :season_number => 6, :episode_number => 9 }
74
75
  episode_results = Tvdbjson::Episode.search_by_season_and_episode(search_query,auth)
75
76
 
77
+ # Return all episodes, on all pages for a series (may take a while)
78
+ search_options = { :series_id => game_of_thrones.id }
79
+ episode_results = Tvdbjson::Episode.all_episodes(search_options,auth)
80
+
76
81
  ```
77
82
 
78
83
  ## License
@@ -1,3 +1,4 @@
1
+ require "pry-byebug"
1
2
  module Tvdbjson
2
3
  class Episode
3
4
  include Tvdbjson::Hashable
@@ -15,6 +16,43 @@ module Tvdbjson
15
16
  @overview = options[:overview]
16
17
  end
17
18
 
19
+ def self.all_episodes(options = {}, authentication)
20
+ raise Tvdbjson::RequiredSeriesIdMissingError if !options[:series_id]
21
+ raise Tvdbjson::AuthenticationObjectMissingError unless authentication.kind_of?(Tvdbjson::Authentication)
22
+
23
+ hash = {
24
+ :method => "GET",
25
+ :uri => "/series/#{options[:series_id]}/episodes",
26
+ :params => { "page" => 1 }
27
+ }
28
+
29
+ # Create an empty array for all episodes
30
+ arr = []
31
+
32
+ # Receive the first page of results
33
+ response = send_authenticated_request(hash, authentication)
34
+
35
+ # Store the Page count to retrieve additional pages in the future
36
+ page_count = get_page_count_from_response(response)
37
+
38
+ # Whilst we have the response object for page 1, let's add it to our array
39
+ arr.concat( Episode.from_response(response,options[:series_id]) )
40
+
41
+ # Now to process the additional pages (starting with page 2)
42
+ (2..page_count).each do |page_number|
43
+ hash = {
44
+ :method => "GET",
45
+ :uri => "/series/#{options[:series_id]}/episodes",
46
+ :params => { "page" => page_number }
47
+ }
48
+ response = send_authenticated_request(hash, authentication)
49
+ arr.concat( Episode.from_response(response,options[:series_id]) )
50
+ end
51
+
52
+ arr
53
+
54
+ end
55
+
18
56
  def self.search_by_season_and_episode(options = {}, authentication)
19
57
  raise Tvdbjson::RequiredSeriesIdMissingError if !options[:series_id]
20
58
  raise Tvdbjson::RequiredSearchParamMissingError if !options[:season_number]
@@ -54,5 +92,9 @@ module Tvdbjson
54
92
  results_array
55
93
  end
56
94
 
95
+ def self.get_page_count_from_response(response)
96
+ response.parsed_response["links"]["last"]
97
+ end
98
+
57
99
  end
58
100
  end
@@ -1,3 +1,3 @@
1
1
  module Tvdbjson
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tvdbjson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Tennant
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-28 00:00:00.000000000 Z
11
+ date: 2017-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry-byebug