where_to 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDgzZmEwODdiY2JjY2E2M2VkNjIyNWFkNGExYTNhYzQwYjNjNmQ0NA==
4
+ YzY0MmExOTdkYjBiMzk1OWQyMmNjNzkyZTk3YmU0MzdiZDMxM2YzNQ==
5
5
  data.tar.gz: !binary |-
6
- NDIwMzRjNjFkMGUxM2MwMDlhNWU1N2RkMTAzNWUxODEyNGRjZWJiZQ==
6
+ ZGEyMDc5NzhhNDliYzFhZDllZjA0NjkwODUyOThlNGM4NDJhZTAwYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2I1NzAxZjQwMTdmYWRkMDgxOWQ1YjVkMzNiOTU5NzZmZmI3NmIwMTM4ZTc4
10
- MTVlNmM4NzgzYjMzOTUxMTY0YjExZjYwYTIyY2M5ZGQ1MTUzZmVhNzZkYWNj
11
- Y2JmNjFjNWI2OTU5N2ZmZTMzMDExNmUyMzY1NTc5MmQxMTVhMTk=
9
+ MGI0MmE3Y2VjNmI4OGE3NWVmMjI1YmM5ZGQyNDI2NGE5YTcyOGQzYTg5Y2Q5
10
+ NTI3YTNiNTQwODg1YWI2YWExZjJhZjQ3Y2I2M2FiNTIyM2IzOTI5ODk3Yzkw
11
+ YWMyZTRiNjFkYmIxNjU3MTMzY2RiNzg4ZjNiZTljM2E3NjM0ZTQ=
12
12
  data.tar.gz: !binary |-
13
- NWVhYzNlYjk3YzI1MmRmNzc3ZWE5YzIxNWRkNTUxMTEzNDZkYmIzYTJjNzM3
14
- MjRkMzQwNDZmODYyYTRhZDc1OWMwMGY0N2I4MWY5ZThiNjY0Y2RjMGZmYmI1
15
- ZTAwYTQwNTUyMGM1MTViMDE3MDFmYmM5OWIzYThjMWI2ZWFkMGE=
13
+ ZGRhZGUxMzBiNjVlOGNjNmY2OWViNmIyZTZjOTJmN2RjYTcxZjUwM2EwZjA2
14
+ NzdhNDJmMDBmNmNiYTMzMWU0MWM1NzNhYjQ3YTdlMmE3ZGFmZmYwNTc5OTE5
15
+ YzFmYTQ5ZjJkNTYwZTIwZGRjZWM2ZWUyNWE1ZmQ5NzNjZTY1NzA=
@@ -1,9 +1,10 @@
1
1
  module WhereTo
2
2
  class Configuration
3
- attr_accessor :folder_format
3
+ attr_accessor :folder_format, :tvdb_api_key
4
4
 
5
5
  def initialize
6
6
  @folder_format = "%series_title/Season %season_number (%season_airdate)/"
7
+ @tvdb_api_key = "You need to get one before you can lookup episode information automatically"
7
8
  end
8
9
 
9
10
  def folder_format
@@ -34,6 +34,11 @@ module WhereTo
34
34
  true
35
35
  end
36
36
 
37
+ def lookup!
38
+ tvdb = WhereTo::TVDB.new params
39
+ load_values_from tvdb.lookup!
40
+ end
41
+
37
42
  def params
38
43
  _params = {}
39
44
  _params[:series_title] = series_title
@@ -0,0 +1,53 @@
1
+ require 'tvdb_party'
2
+
3
+ module WhereTo
4
+ class TVDB
5
+ attr_accessor :series_title, :episode_number, :season, :episode_title
6
+ attr_reader :api_key
7
+
8
+ def initialize(params = {})
9
+ load_values_from params
10
+ @api_key = WhereTo.configuration.tvdb_api_key
11
+ @db = TvdbParty::Search.new api_key
12
+ end
13
+
14
+ def lookup!
15
+ validate!
16
+ results = @db.search(series_title).first
17
+ series = @db.get_series_by_id results['seriesid']
18
+ episode = series.get_episode season, episode_number
19
+ @episode_title = episode.name
20
+
21
+ updated = {}
22
+ updated[:episode_title] = episode_title
23
+ updated
24
+ rescue URI::InvalidURIError
25
+ raise 'You need to configure your TVDB API key before looking up episode information'
26
+ end
27
+
28
+ def validate!
29
+ raise 'A series title is required to lookup episode information' if series_title.nil?
30
+ raise 'An episode number is required to lookup episode information' if episode_number.nil?
31
+ raise 'A season number is required to lookup episode information' if season.nil?
32
+ true
33
+ end
34
+
35
+ private
36
+
37
+ def set_unless_nil(key, value)
38
+ send("#{key}=".to_sym, value) unless value.nil?
39
+ end
40
+
41
+ def load_values_from(hash = {})
42
+ set_unless_nil :series_title, hash[:series_title]
43
+ set_unless_nil :airdate, hash[:airdate]
44
+ set_unless_nil :season, hash[:season_number]
45
+ set_unless_nil :season, hash[:season]
46
+ set_unless_nil :season_airdate, hash[:season_airdate]
47
+ set_unless_nil :episode_title, hash[:episode_title]
48
+ set_unless_nil :episode_number, hash[:episode_number]
49
+ set_unless_nil :episode_quality, hash[:episode_quality]
50
+ set_unless_nil :episode_extension, hash[:episode_extension]
51
+ end
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module WhereTo
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
data/where_to.gemspec CHANGED
@@ -24,4 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "simplecov", "~> 0.10.0"
25
25
  spec.add_development_dependency "coveralls", "~> 0.8.1"
26
26
  spec.add_development_dependency "rspec", "~> 3.2"
27
+
28
+ spec.add_dependency "tvdb_party", "~> 0.8.0"
27
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: where_to
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Toniazzo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-04 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tvdb_party
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.0
83
97
  description:
84
98
  email:
85
99
  - jutonz42@gmail.com
@@ -100,6 +114,7 @@ files:
100
114
  - lib/where_to/episode_formatter.rb
101
115
  - lib/where_to/location.rb
102
116
  - lib/where_to/locator.rb
117
+ - lib/where_to/tvdb.rb
103
118
  - lib/where_to/version.rb
104
119
  - where_to.gemspec
105
120
  homepage: https://github.com/jutonz/where_to