justwatch_client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/lib/just_watch/api.rb +38 -0
- data/lib/just_watch/content.rb +19 -0
- data/lib/just_watch/country.rb +17 -0
- data/lib/just_watch/errors.rb +7 -0
- data/lib/just_watch/genre.rb +17 -0
- data/lib/just_watch/movie.rb +23 -0
- data/lib/just_watch/provider.rb +18 -0
- data/lib/just_watch/season.rb +33 -0
- data/lib/just_watch/tv_show.rb +23 -0
- data/lib/just_watch/version.rb +5 -0
- data/lib/just_watch.rb +16 -0
- data/lib/just_watch_client.rb +3 -0
- data/lib/justwatch_client.rb +3 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bbb06db4709d3bd4f3daec9ca5713657f72faecce2439fe5c83cecf4875eb437
|
4
|
+
data.tar.gz: af20dd04cf13a70e6a3efb7a9dd4b475f2dd03f31c660f8808c60dbb53c004f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54fd59e941499fb630d73960f9a3936104090f3f8dcc72b8872abe9ef519cc50daa9ee8077129a767deb36b21d69a809c421140aecf124e452783666f264eb85
|
7
|
+
data.tar.gz: 8b4c816c82bb9350bb6d18cd644aa6627d62619d32983ddb2ee4876c16a382cca79f193aa5fc3548255ced7c9f091935ce62d6adebe13f0056abe7a4e9cc840a
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Cineol
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
class Api
|
5
|
+
DEFAULT_LOCALE = 'en_US'
|
6
|
+
API_VERSION_URL = '/contentpartner/v2/content'
|
7
|
+
DOMAIN_URL = 'https://apis.justwatch.com'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_writer :locale
|
11
|
+
attr_accessor :token
|
12
|
+
|
13
|
+
def locale
|
14
|
+
@locale ||= DEFAULT_LOCALE
|
15
|
+
end
|
16
|
+
|
17
|
+
def request(path, params = {})
|
18
|
+
connection.get([API_VERSION_URL, path].join, params.merge!(token: token)).body
|
19
|
+
rescue Faraday::ResourceNotFound
|
20
|
+
raise JustWatch::NotFoundError
|
21
|
+
rescue Faraday::UnauthorizedError
|
22
|
+
raise JustWatch::UnauthorizedError
|
23
|
+
rescue Faraday::ServerError
|
24
|
+
raise JustWatch::ServerError
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def connection
|
30
|
+
Faraday.new(DOMAIN_URL) do |faraday_connection|
|
31
|
+
faraday_connection.request :json
|
32
|
+
faraday_connection.response :json, parser_options: { symbolize_names: true }
|
33
|
+
faraday_connection.response :raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
Content = Struct.new(:title, :original_title, :original_release_year, :director, :full_path, :justwatch_id,
|
5
|
+
:imdb_id, :tmdb_id, :production_countries, :original_language, :runtime, :object_type,
|
6
|
+
:genre_ids, :offers, keyword_init: true) do
|
7
|
+
class << self
|
8
|
+
private
|
9
|
+
|
10
|
+
def offers_by_id_path(object_type, service_id_type, locale)
|
11
|
+
"/offers/object_type/#{object_type}/id_type/#{service_id_type}/locale/#{locale}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def offers_by_title_and_year_path(object_type, locale)
|
15
|
+
"/offers/object_type/#{object_type}/locale/#{locale}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
Country = Struct.new(:url_part, :full_locale, :status, :country, :currency, keyword_init: true) do
|
5
|
+
class << self
|
6
|
+
COUNTRY_PATH = '/countries'
|
7
|
+
|
8
|
+
def list
|
9
|
+
countries = Api.request(COUNTRY_PATH)
|
10
|
+
|
11
|
+
countries.map do |country|
|
12
|
+
new(country.slice(*members))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
Genre = Struct.new(:id, :translation, :short_name, :technical_name, keyword_init: true) do
|
5
|
+
class << self
|
6
|
+
GENRE_PATH = '/genres/all/locale'
|
7
|
+
|
8
|
+
def list(locale: Api.locale)
|
9
|
+
genres = Api.request([GENRE_PATH, locale].join('/'))
|
10
|
+
|
11
|
+
genres.map do |genre|
|
12
|
+
new(genre.slice(*members))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
class Movie < Content
|
5
|
+
MOVIE_CONTENT_TYPE = 'movie'
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def offers_by_id(id:, service_id_type:, locale: Api.locale)
|
9
|
+
movie = Api.request(offers_by_id_path(MOVIE_CONTENT_TYPE, service_id_type, locale), id: id)
|
10
|
+
|
11
|
+
new(movie.slice(*members))
|
12
|
+
end
|
13
|
+
|
14
|
+
def offers_by_title_and_year(title:, year:, locale: Api.locale)
|
15
|
+
movie = Api.request(
|
16
|
+
offers_by_title_and_year_path(MOVIE_CONTENT_TYPE, locale),
|
17
|
+
title: title, release_year: year
|
18
|
+
)
|
19
|
+
new(movie.slice(*members))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
Provider = Struct.new(:id, :technical_name, :short_name, :clear_name, :monetization_types, :icon_url, :slug,
|
5
|
+
keyword_init: true) do
|
6
|
+
class << self
|
7
|
+
PROVIDER_PATH = '/providers/all/locale'
|
8
|
+
|
9
|
+
def list(locale: Api.locale)
|
10
|
+
providers = Api.request([PROVIDER_PATH, locale].join('/'))
|
11
|
+
|
12
|
+
providers.map do |provider|
|
13
|
+
new(provider.slice(*members))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
Season = Struct.new(*JustWatch::Content.members, :episodes, :season_number, keyword_init: true) do
|
5
|
+
class << self
|
6
|
+
def offers_by_id_and_season_number(id:, service_id_type:, season_number:, locale: Api.locale)
|
7
|
+
season = Api.request(
|
8
|
+
offers_by_id_and_season_number_path(service_id_type, season_number, locale), id: id
|
9
|
+
)
|
10
|
+
|
11
|
+
new(season.slice(*members))
|
12
|
+
end
|
13
|
+
|
14
|
+
def offers_by_title_year_and_season_number(title:, year:, season_number:, locale: Api.locale)
|
15
|
+
season = Api.request(
|
16
|
+
offers_by_title_year_and_season_number_path(season_number, locale), title: title, release_year: year
|
17
|
+
)
|
18
|
+
|
19
|
+
new(season.slice(*members))
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def offers_by_id_and_season_number_path(service_id_type, season_number, locale)
|
25
|
+
"/offers/object_type/show/id_type/#{service_id_type}/season_number/#{season_number}/locale/#{locale}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def offers_by_title_year_and_season_number_path(season_number, locale)
|
29
|
+
"/offers/object_type/show/season_number/#{season_number}/locale/#{locale}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JustWatch
|
4
|
+
class TvShow < Content
|
5
|
+
TV_SHOW_CONTENT_TYPE = 'show'
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def offers_by_id(id:, service_id_type:, locale: Api.locale)
|
9
|
+
tv_show = Api.request(offers_by_id_path(TV_SHOW_CONTENT_TYPE, service_id_type, locale), id: id)
|
10
|
+
|
11
|
+
new(tv_show.slice(*members))
|
12
|
+
end
|
13
|
+
|
14
|
+
def offers_by_title_and_year(title:, year:, locale: Api.locale)
|
15
|
+
tv_show = Api.request(
|
16
|
+
offers_by_title_and_year_path(TV_SHOW_CONTENT_TYPE, locale),
|
17
|
+
title: title, release_year: year
|
18
|
+
)
|
19
|
+
new(tv_show.slice(*members))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/just_watch.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
require 'just_watch/api'
|
6
|
+
require 'just_watch/errors'
|
7
|
+
require 'just_watch/content'
|
8
|
+
require 'just_watch/country'
|
9
|
+
require 'just_watch/genre'
|
10
|
+
require 'just_watch/movie'
|
11
|
+
require 'just_watch/provider'
|
12
|
+
require 'just_watch/season'
|
13
|
+
require 'just_watch/tv_show'
|
14
|
+
|
15
|
+
module JustWatch
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: justwatch_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alejandro Perea
|
8
|
+
- Josep Casanovas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2022-11-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1'
|
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'
|
84
|
+
description: Ruby API Client for JustWatch.
|
85
|
+
email:
|
86
|
+
- alejandro.perea.fdez@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files:
|
90
|
+
- README.md
|
91
|
+
files:
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- lib/just_watch.rb
|
95
|
+
- lib/just_watch/api.rb
|
96
|
+
- lib/just_watch/content.rb
|
97
|
+
- lib/just_watch/country.rb
|
98
|
+
- lib/just_watch/errors.rb
|
99
|
+
- lib/just_watch/genre.rb
|
100
|
+
- lib/just_watch/movie.rb
|
101
|
+
- lib/just_watch/provider.rb
|
102
|
+
- lib/just_watch/season.rb
|
103
|
+
- lib/just_watch/tv_show.rb
|
104
|
+
- lib/just_watch/version.rb
|
105
|
+
- lib/just_watch_client.rb
|
106
|
+
- lib/justwatch_client.rb
|
107
|
+
homepage: https://github.com/cineol-gems/justwatch-client
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options:
|
113
|
+
- "--charset=UTF-8"
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '2.7'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubygems_version: 3.3.7
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: Ruby API Client for JustWatch
|
131
|
+
test_files: []
|