justwatch_client 0.1.0 → 0.3.0
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 +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +162 -1
- data/lib/just_watch/api.rb +1 -1
- data/lib/just_watch/country.rb +7 -3
- data/lib/just_watch/genre.rb +7 -3
- data/lib/just_watch/provider.rb +7 -3
- data/lib/just_watch/version.rb +1 -1
- metadata +13 -66
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 934c78534a6360e729b7fb12a2e308b22c1ca18fcecbf8de2f4ce41d7e78671d
|
|
4
|
+
data.tar.gz: d24e44e8f24fd081aff16bf901e6741ad40060e3ba0b077c0c43f42a2cd68659
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: adc769c12fb41be5e86d8019db486bc9ccca128a64388ab9f6aaa67989f3f729c3d4c083836f81bc610e19ff06e0b8e84c467d19667d8b5b0e7a739f562526d1
|
|
7
|
+
data.tar.gz: 0bc7080912a836b3f9674484aede00ccf28aaa2694c26d1f45e6ada381fcc8f5c977065342482a0b0440fcafab0c206536e7e93c4c1372a18a418dfecf56f4b8
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.3.0]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Breaking:** Ruby 3.3 is now the minimum supported version (was 2.7).
|
|
13
|
+
- **Breaking:** Faraday is now required at `~> 2.0` (was `>= 1, < 3`). Faraday 1 is
|
|
14
|
+
end-of-life, and the JSON middleware this gem relies on only reached Faraday core
|
|
15
|
+
in 1.10, so the old constraint advertised support that never worked in practice.
|
|
16
|
+
- `JustWatch::Api.request` no longer mutates the `params` hash it is given; the API
|
|
17
|
+
token is merged into a copy.
|
|
18
|
+
- Development dependencies updated: RuboCop `~> 1.90`, WebMock `~> 3.26`,
|
|
19
|
+
debug `~> 1.11`. Added Rake `~> 13.4` and a `Rakefile` with a default
|
|
20
|
+
`spec` + `rubocop` task.
|
|
21
|
+
- CI now tests against Ruby 3.3, 3.4 and 4.0; the end-of-life 3.1 and 3.2 entries
|
|
22
|
+
were removed.
|
|
23
|
+
- The gemspec builds its file list from a `Dir` glob instead of shelling out to
|
|
24
|
+
`git ls-files`, and now declares `rubygems_mfa_required` along with the usual
|
|
25
|
+
source, changelog and bug tracker metadata.
|
|
26
|
+
|
|
27
|
+
### Internal
|
|
28
|
+
|
|
29
|
+
- The private `COUNTRY_PATH`, `GENRE_PATH` and `PROVIDER_PATH` constants (which were
|
|
30
|
+
defined on the singleton class and therefore unreachable as
|
|
31
|
+
`JustWatch::Genre::GENRE_PATH`) are now private class methods, matching the path
|
|
32
|
+
helpers already used by `JustWatch::Content`.
|
|
33
|
+
|
|
34
|
+
## [0.2.0]
|
|
35
|
+
|
|
36
|
+
- Initial documented release.
|
data/README.md
CHANGED
|
@@ -1,2 +1,163 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Justwatch client
|
|
2
|
+
|
|
2
3
|
Ruby Client for JustWatch API
|
|
4
|
+
|
|
5
|
+
Requires Ruby >= 3.3.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add it to your `Gemfile`:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'justwatch_client'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then run `bundle install`. Or install it directly:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
gem install justwatch_client
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## How to configure
|
|
22
|
+
|
|
23
|
+
If you are using Rails, the better way is to define an initializer in `config/initializers`, defining the default locale and the token (we encourage to not push the token to the repo).
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
# config/initializers/justwatch.rb
|
|
27
|
+
|
|
28
|
+
JustWatch::Api.locale = 'es_ES'
|
|
29
|
+
JustWatch::Api.token = ENV.fetch('JUSTWATCH_API_TOKEN', nil)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The locale defined here is the **default**, you can override it in the different calls.
|
|
33
|
+
|
|
34
|
+
## General Provider Info
|
|
35
|
+
|
|
36
|
+
We can fetch the data for providers with the following call:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
JustWatch::Provider.list(locale:)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
| Parameter | Explanation | Example values |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Genres list
|
|
48
|
+
|
|
49
|
+
We can fetch the genre list with the following call:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
JustWatch::Genre.list(locale:)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
| Parameter | Explanation | Example values |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Country list
|
|
61
|
+
|
|
62
|
+
We can fetch the country list with the following call:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
JustWatch::Country.list(locale:)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Parameter | Explanation | Example values |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## Movie offers by ID
|
|
74
|
+
|
|
75
|
+
We can fetch the data for a movie using a service ID with the following call:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
JustWatch::Movie.offers_by_id(id:, service_id_type:, locale:)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| Parameter | Explanation | Example values |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `id` | TMDB, IMDB or Justwatch ID | `12345`, `tt0125439`, `39130` |
|
|
84
|
+
| `service_id_type` | Service for which the ID has been provided | `tmdb`, `imdb` or `justwatch` |
|
|
85
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## Movie offers by title and year
|
|
89
|
+
|
|
90
|
+
We can fetch the data for a movie using title and year with the following call:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
JustWatch::Movie.offers_by_title_and_year(title:, year:, locale: Api.locale)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Parameter | Explanation | Example values |
|
|
97
|
+
| --- | --- | --- |
|
|
98
|
+
| `title` | Movie title | `12 monkeys`, `The Shining` |
|
|
99
|
+
| `year` | Movie release year | `1999`, `2021` |
|
|
100
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
101
|
+
|
|
102
|
+
## TvShow offers by ID
|
|
103
|
+
|
|
104
|
+
We can fetch the data for a tv show using a service ID with the following call:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
JustWatch::TvShow.offers_by_id(id:, service_id_type:, locale:)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
| Parameter | Explanation | Example values |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| `id` | TMDB, IMDB or Justwatch ID | `12345`, `tt0125439`, `39130` |
|
|
113
|
+
| `service_id_type` | Service for which the ID has been provided | `tmdb`, `imdb` or `justwatch` |
|
|
114
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
115
|
+
|
|
116
|
+
## TvShow offers by title and year
|
|
117
|
+
|
|
118
|
+
We can fetch the data for a tv show using the tv show title and the year with the following call:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
JustWatch::TvShow.offers_by_title_and_year(title:, year:, locale:)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
| Parameter | Explanation | Example values |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
| `title` | Tv show title | `House`, `Lost` |
|
|
127
|
+
| `year` | Tv show release year | `2004`, `2021` |
|
|
128
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
129
|
+
|
|
130
|
+
## Season offers by id and season number
|
|
131
|
+
|
|
132
|
+
We can fetch the data for a season using the tv show ID and the season number with the following call:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
JustWatch::Season.offers_by_id_and_season_number(id:, service_id_type:, season_number:, locale:)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
| Parameter | Explanation | Example values |
|
|
139
|
+
| --- | --- | --- |
|
|
140
|
+
| `id` | TMDB, IMDB or Justwatch **tv show** ID | `12345`, `tt0125439`, `39130` |
|
|
141
|
+
| `service_id_type` | Service for which the ID has been provided | `tmdb`, `imdb` or `justwatch` |
|
|
142
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
143
|
+
|
|
144
|
+
## Season offers by title, year and season number
|
|
145
|
+
|
|
146
|
+
We can fetch the data for a season using the tv show tv show title, year and season number with the following call:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
JustWatch::Season::offers_by_title_year_and_season_number(title:, year:, season_number:, locale:)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
| Parameter | Explanation | Example values |
|
|
153
|
+
| --- | --- | --- |
|
|
154
|
+
| `title` | Tv show title | `House`, `Lost` |
|
|
155
|
+
| `year` | Tv show release year | `2004`, `2021` |
|
|
156
|
+
| `season_number` | Tv show season number | `1`, `2` |
|
|
157
|
+
| `locale` (optional) | Locale you are searching for | `es_ES`, `en_US` |
|
|
158
|
+
|
|
159
|
+
## Troubleshoot
|
|
160
|
+
|
|
161
|
+
### Locale
|
|
162
|
+
|
|
163
|
+
Your JustWatch account is restricted to a bunch of locales. If you are getting Unauthorized errors this could be the reason.
|
data/lib/just_watch/api.rb
CHANGED
|
@@ -15,7 +15,7 @@ module JustWatch
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def request(path, params = {})
|
|
18
|
-
connection.get([API_VERSION_URL, path].join, params.merge
|
|
18
|
+
connection.get([API_VERSION_URL, path].join, params.merge(token: token)).body
|
|
19
19
|
rescue Faraday::ResourceNotFound
|
|
20
20
|
raise JustWatch::NotFoundError
|
|
21
21
|
rescue Faraday::UnauthorizedError
|
data/lib/just_watch/country.rb
CHANGED
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
module JustWatch
|
|
4
4
|
Country = Struct.new(:url_part, :full_locale, :status, :country, :currency, keyword_init: true) do
|
|
5
5
|
class << self
|
|
6
|
-
COUNTRY_PATH = '/countries'
|
|
7
|
-
|
|
8
6
|
def list
|
|
9
|
-
countries = Api.request(
|
|
7
|
+
countries = Api.request(countries_path)
|
|
10
8
|
|
|
11
9
|
countries.map do |country|
|
|
12
10
|
new(country.slice(*members))
|
|
13
11
|
end
|
|
14
12
|
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def countries_path
|
|
17
|
+
'/countries'
|
|
18
|
+
end
|
|
15
19
|
end
|
|
16
20
|
end
|
|
17
21
|
end
|
data/lib/just_watch/genre.rb
CHANGED
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
module JustWatch
|
|
4
4
|
Genre = Struct.new(:id, :translation, :short_name, :technical_name, keyword_init: true) do
|
|
5
5
|
class << self
|
|
6
|
-
GENRE_PATH = '/genres/all/locale'
|
|
7
|
-
|
|
8
6
|
def list(locale: Api.locale)
|
|
9
|
-
genres = Api.request(
|
|
7
|
+
genres = Api.request(genres_path(locale))
|
|
10
8
|
|
|
11
9
|
genres.map do |genre|
|
|
12
10
|
new(genre.slice(*members))
|
|
13
11
|
end
|
|
14
12
|
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def genres_path(locale)
|
|
17
|
+
"/genres/all/locale/#{locale}"
|
|
18
|
+
end
|
|
15
19
|
end
|
|
16
20
|
end
|
|
17
21
|
end
|
data/lib/just_watch/provider.rb
CHANGED
|
@@ -4,15 +4,19 @@ module JustWatch
|
|
|
4
4
|
Provider = Struct.new(:id, :technical_name, :short_name, :clear_name, :monetization_types, :icon_url, :slug,
|
|
5
5
|
keyword_init: true) do
|
|
6
6
|
class << self
|
|
7
|
-
PROVIDER_PATH = '/providers/all/locale'
|
|
8
|
-
|
|
9
7
|
def list(locale: Api.locale)
|
|
10
|
-
providers = Api.request(
|
|
8
|
+
providers = Api.request(providers_path(locale))
|
|
11
9
|
|
|
12
10
|
providers.map do |provider|
|
|
13
11
|
new(provider.slice(*members))
|
|
14
12
|
end
|
|
15
13
|
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def providers_path(locale)
|
|
18
|
+
"/providers/all/locale/#{locale}"
|
|
19
|
+
end
|
|
16
20
|
end
|
|
17
21
|
end
|
|
18
22
|
end
|
data/lib/just_watch/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: justwatch_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alejandro Perea
|
|
8
8
|
- Josep Casanovas
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: faraday
|
|
@@ -17,70 +16,14 @@ dependencies:
|
|
|
17
16
|
requirements:
|
|
18
17
|
- - "~>"
|
|
19
18
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
19
|
+
version: '2.0'
|
|
21
20
|
type: :runtime
|
|
22
21
|
prerelease: false
|
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
23
|
requirements:
|
|
25
24
|
- - "~>"
|
|
26
25
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: debug
|
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
|
31
|
-
requirements:
|
|
32
|
-
- - "~>"
|
|
33
|
-
- !ruby/object:Gem::Version
|
|
34
|
-
version: '1.6'
|
|
35
|
-
type: :development
|
|
36
|
-
prerelease: false
|
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
-
requirements:
|
|
39
|
-
- - "~>"
|
|
40
|
-
- !ruby/object:Gem::Version
|
|
41
|
-
version: '1.6'
|
|
42
|
-
- !ruby/object:Gem::Dependency
|
|
43
|
-
name: rspec
|
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
|
45
|
-
requirements:
|
|
46
|
-
- - "~>"
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version: '3.11'
|
|
49
|
-
type: :development
|
|
50
|
-
prerelease: false
|
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
-
requirements:
|
|
53
|
-
- - "~>"
|
|
54
|
-
- !ruby/object:Gem::Version
|
|
55
|
-
version: '3.11'
|
|
56
|
-
- !ruby/object:Gem::Dependency
|
|
57
|
-
name: rubocop
|
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
|
59
|
-
requirements:
|
|
60
|
-
- - "~>"
|
|
61
|
-
- !ruby/object:Gem::Version
|
|
62
|
-
version: '1.36'
|
|
63
|
-
type: :development
|
|
64
|
-
prerelease: false
|
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
-
requirements:
|
|
67
|
-
- - "~>"
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
version: '1.36'
|
|
70
|
-
- !ruby/object:Gem::Dependency
|
|
71
|
-
name: webmock
|
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
|
73
|
-
requirements:
|
|
74
|
-
- - "~>"
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: '3.18'
|
|
77
|
-
type: :development
|
|
78
|
-
prerelease: false
|
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
-
requirements:
|
|
81
|
-
- - "~>"
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
version: '3.18'
|
|
26
|
+
version: '2.0'
|
|
84
27
|
description: Ruby API Client for JustWatch.
|
|
85
28
|
email:
|
|
86
29
|
- alejandro.perea.fdez@gmail.com
|
|
@@ -89,6 +32,7 @@ extensions: []
|
|
|
89
32
|
extra_rdoc_files:
|
|
90
33
|
- README.md
|
|
91
34
|
files:
|
|
35
|
+
- CHANGELOG.md
|
|
92
36
|
- LICENSE
|
|
93
37
|
- README.md
|
|
94
38
|
- lib/just_watch.rb
|
|
@@ -107,8 +51,12 @@ files:
|
|
|
107
51
|
homepage: https://github.com/cineol-gems/justwatch-client
|
|
108
52
|
licenses:
|
|
109
53
|
- MIT
|
|
110
|
-
metadata:
|
|
111
|
-
|
|
54
|
+
metadata:
|
|
55
|
+
homepage_uri: https://github.com/cineol-gems/justwatch-client
|
|
56
|
+
source_code_uri: https://github.com/cineol-gems/justwatch-client
|
|
57
|
+
changelog_uri: https://github.com/cineol-gems/justwatch-client/blob/main/CHANGELOG.md
|
|
58
|
+
bug_tracker_uri: https://github.com/cineol-gems/justwatch-client/issues
|
|
59
|
+
rubygems_mfa_required: 'true'
|
|
112
60
|
rdoc_options:
|
|
113
61
|
- "--charset=UTF-8"
|
|
114
62
|
require_paths:
|
|
@@ -117,15 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
117
65
|
requirements:
|
|
118
66
|
- - ">="
|
|
119
67
|
- !ruby/object:Gem::Version
|
|
120
|
-
version: '
|
|
68
|
+
version: '3.3'
|
|
121
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
70
|
requirements:
|
|
123
71
|
- - ">="
|
|
124
72
|
- !ruby/object:Gem::Version
|
|
125
73
|
version: '0'
|
|
126
74
|
requirements: []
|
|
127
|
-
rubygems_version: 3.
|
|
128
|
-
signing_key:
|
|
75
|
+
rubygems_version: 3.6.9
|
|
129
76
|
specification_version: 4
|
|
130
77
|
summary: Ruby API Client for JustWatch
|
|
131
78
|
test_files: []
|