tvdb_api 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tvdb_api/tvdb_api.rb +17 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 500991e66e3a7796958cef67f45c68c7300f07ab27fcd5e030da6f469ad2f818
|
4
|
+
data.tar.gz: d4440345615bd0d8608e50875d9ba4106bb710048c85b4a07ca7a8c8e9b30853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7530d15e2af662a2a269af7de1647da8056f464d8e66b149b8d728a70f3755e6cdf20f137eb558639ca41712087d29b3f7083674441e910085596cfde88d3502
|
7
|
+
data.tar.gz: 114056201fd465964175274ea180025de4b80b8faebf59f737faa4787e8f5721c36c0bdaaa9ccd8d6780fa27b8186d64ed29b9ebca04cf4cfc1a5af9ae1befa5
|
data/lib/tvdb_api/tvdb_api.rb
CHANGED
@@ -5,10 +5,12 @@ require 'json'
|
|
5
5
|
require_relative 'tvdb_api_middleware'
|
6
6
|
|
7
7
|
class TVDBApi
|
8
|
-
|
9
8
|
BASE_URL = 'https://api4.thetvdb.com'
|
10
9
|
ENDPOINTS = {
|
11
10
|
search: '/v4/search',
|
11
|
+
movie: '/v4/movies/%{id}/extended',
|
12
|
+
series: '/v4/series/%{id}/extended',
|
13
|
+
person: '/v4/people/%{id}/extended'
|
12
14
|
}
|
13
15
|
|
14
16
|
def initialize
|
@@ -23,19 +25,23 @@ class TVDBApi
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def search(query)
|
26
|
-
request_endpoint(:search, { query:
|
28
|
+
request_endpoint(:search, { query: })
|
29
|
+
end
|
30
|
+
|
31
|
+
def search_by_type(query, type)
|
32
|
+
request_endpoint(:search, query: query, type: type)
|
27
33
|
end
|
28
34
|
|
29
|
-
def
|
30
|
-
request_endpoint(:
|
35
|
+
def movie(id)
|
36
|
+
request_endpoint(:movie, id: id)
|
31
37
|
end
|
32
38
|
|
33
|
-
def
|
34
|
-
request_endpoint(:
|
39
|
+
def series(id)
|
40
|
+
request_endpoint(:series, id: id)
|
35
41
|
end
|
36
42
|
|
37
|
-
def
|
38
|
-
request_endpoint(:
|
43
|
+
def person(id)
|
44
|
+
request_endpoint(:person, id: id)
|
39
45
|
end
|
40
46
|
|
41
47
|
private
|
@@ -44,9 +50,11 @@ class TVDBApi
|
|
44
50
|
url = ENDPOINTS[endpoint_key]
|
45
51
|
raise "Invalid endpoint key: #{endpoint_key}" unless url
|
46
52
|
|
53
|
+
url = url % params if url.include?('%{')
|
54
|
+
|
47
55
|
response = @conn.get do |req|
|
48
56
|
req.url url
|
49
|
-
req.params = params
|
57
|
+
req.params = params.reject { |k, _| url.include?("%{#{k}}") }
|
50
58
|
end
|
51
59
|
|
52
60
|
JSON.parse(response.body)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tvdb_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen McCullough
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|