plex_ruby_sdk 0.7.7 → 0.8.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/lib/plex_ruby_sdk/activities.rb +115 -12
- data/lib/plex_ruby_sdk/authentication.rb +233 -29
- data/lib/plex_ruby_sdk/butler.rb +283 -30
- data/lib/plex_ruby_sdk/hubs.rb +174 -21
- data/lib/plex_ruby_sdk/library.rb +913 -110
- data/lib/plex_ruby_sdk/log.rb +179 -24
- data/lib/plex_ruby_sdk/media.rb +288 -35
- data/lib/plex_ruby_sdk/playlists.rb +513 -60
- data/lib/plex_ruby_sdk/plex.rb +388 -38
- data/lib/plex_ruby_sdk/plex_api.rb +29 -10
- data/lib/plex_ruby_sdk/sdk_hooks/hooks.rb +103 -0
- data/lib/plex_ruby_sdk/sdk_hooks/registration.rb +35 -0
- data/lib/plex_ruby_sdk/sdk_hooks/types.rb +152 -0
- data/lib/plex_ruby_sdk/sdkconfiguration.rb +26 -7
- data/lib/plex_ruby_sdk/search.rb +174 -21
- data/lib/plex_ruby_sdk/server.rb +505 -53
- data/lib/plex_ruby_sdk/sessions.rb +228 -25
- data/lib/plex_ruby_sdk/statistics.rb +174 -21
- data/lib/plex_ruby_sdk/updater.rb +173 -20
- data/lib/plex_ruby_sdk/users.rb +56 -4
- data/lib/plex_ruby_sdk/utils/retries.rb +95 -0
- data/lib/plex_ruby_sdk/utils/utils.rb +10 -0
- data/lib/plex_ruby_sdk/video.rb +117 -14
- data/lib/plex_ruby_sdk/watchlist.rb +60 -7
- metadata +36 -4
@@ -5,7 +5,10 @@
|
|
5
5
|
|
6
6
|
require 'faraday'
|
7
7
|
require 'faraday/multipart'
|
8
|
+
require 'faraday/retry'
|
8
9
|
require 'sorbet-runtime'
|
10
|
+
require_relative 'sdk_hooks/hooks'
|
11
|
+
require_relative 'utils/retries'
|
9
12
|
|
10
13
|
module PlexRubySDK
|
11
14
|
extend T::Sig
|
@@ -23,8 +26,8 @@ module PlexRubySDK
|
|
23
26
|
end
|
24
27
|
|
25
28
|
|
26
|
-
sig { params(request: T.nilable(::PlexRubySDK::Operations::CreatePlaylistRequest)).returns(::PlexRubySDK::Operations::CreatePlaylistResponse) }
|
27
|
-
def create_playlist(request)
|
29
|
+
sig { params(request: T.nilable(::PlexRubySDK::Operations::CreatePlaylistRequest), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::CreatePlaylistResponse) }
|
30
|
+
def create_playlist(request, timeout_ms = nil)
|
28
31
|
# create_playlist - Create a Playlist
|
29
32
|
# Create a new playlist. By default the playlist is blank. To create a playlist along with a first item, pass:
|
30
33
|
# - `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
|
@@ -38,11 +41,61 @@ module PlexRubySDK
|
|
38
41
|
headers['Accept'] = 'application/json'
|
39
42
|
headers['user-agent'] = @sdk_configuration.user_agent
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
45
|
+
|
46
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
47
|
+
timeout ||= @sdk_configuration.timeout
|
48
|
+
|
49
|
+
connection = @sdk_configuration.client
|
50
|
+
|
51
|
+
hook_ctx = SDKHooks::HookContext.new(
|
52
|
+
base_url: base_url,
|
53
|
+
oauth2_scopes: nil,
|
54
|
+
operation_id: 'createPlaylist',
|
55
|
+
security_source: @sdk_configuration.security_source
|
56
|
+
)
|
57
|
+
|
58
|
+
error = T.let(nil, T.nilable(StandardError))
|
59
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
60
|
+
|
61
|
+
begin
|
62
|
+
r = connection.post(url) do |req|
|
63
|
+
req.headers.merge!(headers)
|
64
|
+
req.options.timeout = timeout unless timeout.nil?
|
65
|
+
req.params = query_params
|
66
|
+
Utils.configure_request_security(req, security)
|
67
|
+
|
68
|
+
@sdk_configuration.hooks.before_request(
|
69
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
70
|
+
hook_ctx: hook_ctx
|
71
|
+
),
|
72
|
+
request: req
|
73
|
+
)
|
74
|
+
end
|
75
|
+
rescue StandardError => e
|
76
|
+
error = e
|
77
|
+
ensure
|
78
|
+
if r.nil? || Utils.error_status?(r.status)
|
79
|
+
r = @sdk_configuration.hooks.after_error(
|
80
|
+
error: error,
|
81
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
82
|
+
hook_ctx: hook_ctx
|
83
|
+
),
|
84
|
+
response: r
|
85
|
+
)
|
86
|
+
else
|
87
|
+
r = @sdk_configuration.hooks.after_success(
|
88
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
89
|
+
hook_ctx: hook_ctx
|
90
|
+
),
|
91
|
+
response: r
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
if r.nil?
|
96
|
+
raise error if !error.nil?
|
97
|
+
raise 'no response'
|
98
|
+
end
|
46
99
|
end
|
47
100
|
|
48
101
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -71,8 +124,8 @@ module PlexRubySDK
|
|
71
124
|
end
|
72
125
|
|
73
126
|
|
74
|
-
sig { params(playlist_type: T.nilable(::PlexRubySDK::Operations::PlaylistType), smart: T.nilable(::PlexRubySDK::Operations::QueryParamSmart)).returns(::PlexRubySDK::Operations::GetPlaylistsResponse) }
|
75
|
-
def get_playlists(playlist_type = nil, smart = nil)
|
127
|
+
sig { params(playlist_type: T.nilable(::PlexRubySDK::Operations::PlaylistType), smart: T.nilable(::PlexRubySDK::Operations::QueryParamSmart), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetPlaylistsResponse) }
|
128
|
+
def get_playlists(playlist_type = nil, smart = nil, timeout_ms = nil)
|
76
129
|
# get_playlists - Get All Playlists
|
77
130
|
# Get All Playlists given the specified filters.
|
78
131
|
request = ::PlexRubySDK::Operations::GetPlaylistsRequest.new(
|
@@ -88,11 +141,61 @@ module PlexRubySDK
|
|
88
141
|
headers['Accept'] = 'application/json'
|
89
142
|
headers['user-agent'] = @sdk_configuration.user_agent
|
90
143
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
144
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
145
|
+
|
146
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
147
|
+
timeout ||= @sdk_configuration.timeout
|
148
|
+
|
149
|
+
connection = @sdk_configuration.client
|
150
|
+
|
151
|
+
hook_ctx = SDKHooks::HookContext.new(
|
152
|
+
base_url: base_url,
|
153
|
+
oauth2_scopes: nil,
|
154
|
+
operation_id: 'getPlaylists',
|
155
|
+
security_source: @sdk_configuration.security_source
|
156
|
+
)
|
157
|
+
|
158
|
+
error = T.let(nil, T.nilable(StandardError))
|
159
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
160
|
+
|
161
|
+
begin
|
162
|
+
r = connection.get(url) do |req|
|
163
|
+
req.headers.merge!(headers)
|
164
|
+
req.options.timeout = timeout unless timeout.nil?
|
165
|
+
req.params = query_params
|
166
|
+
Utils.configure_request_security(req, security)
|
167
|
+
|
168
|
+
@sdk_configuration.hooks.before_request(
|
169
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
170
|
+
hook_ctx: hook_ctx
|
171
|
+
),
|
172
|
+
request: req
|
173
|
+
)
|
174
|
+
end
|
175
|
+
rescue StandardError => e
|
176
|
+
error = e
|
177
|
+
ensure
|
178
|
+
if r.nil? || Utils.error_status?(r.status)
|
179
|
+
r = @sdk_configuration.hooks.after_error(
|
180
|
+
error: error,
|
181
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
182
|
+
hook_ctx: hook_ctx
|
183
|
+
),
|
184
|
+
response: r
|
185
|
+
)
|
186
|
+
else
|
187
|
+
r = @sdk_configuration.hooks.after_success(
|
188
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
189
|
+
hook_ctx: hook_ctx
|
190
|
+
),
|
191
|
+
response: r
|
192
|
+
)
|
193
|
+
end
|
194
|
+
|
195
|
+
if r.nil?
|
196
|
+
raise error if !error.nil?
|
197
|
+
raise 'no response'
|
198
|
+
end
|
96
199
|
end
|
97
200
|
|
98
201
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -121,8 +224,8 @@ module PlexRubySDK
|
|
121
224
|
end
|
122
225
|
|
123
226
|
|
124
|
-
sig { params(playlist_id: ::Float).returns(::PlexRubySDK::Operations::GetPlaylistResponse) }
|
125
|
-
def get_playlist(playlist_id)
|
227
|
+
sig { params(playlist_id: ::Float, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetPlaylistResponse) }
|
228
|
+
def get_playlist(playlist_id, timeout_ms = nil)
|
126
229
|
# get_playlist - Retrieve Playlist
|
127
230
|
# Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
|
128
231
|
# Smart playlist details contain the `content` attribute. This is the content URI for the generator. This can then be parsed by a client to provide smart playlist editing.
|
@@ -143,10 +246,60 @@ module PlexRubySDK
|
|
143
246
|
headers['Accept'] = 'application/json'
|
144
247
|
headers['user-agent'] = @sdk_configuration.user_agent
|
145
248
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
249
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
250
|
+
|
251
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
252
|
+
timeout ||= @sdk_configuration.timeout
|
253
|
+
|
254
|
+
connection = @sdk_configuration.client
|
255
|
+
|
256
|
+
hook_ctx = SDKHooks::HookContext.new(
|
257
|
+
base_url: base_url,
|
258
|
+
oauth2_scopes: nil,
|
259
|
+
operation_id: 'getPlaylist',
|
260
|
+
security_source: @sdk_configuration.security_source
|
261
|
+
)
|
262
|
+
|
263
|
+
error = T.let(nil, T.nilable(StandardError))
|
264
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
265
|
+
|
266
|
+
begin
|
267
|
+
r = connection.get(url) do |req|
|
268
|
+
req.headers.merge!(headers)
|
269
|
+
req.options.timeout = timeout unless timeout.nil?
|
270
|
+
Utils.configure_request_security(req, security)
|
271
|
+
|
272
|
+
@sdk_configuration.hooks.before_request(
|
273
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
274
|
+
hook_ctx: hook_ctx
|
275
|
+
),
|
276
|
+
request: req
|
277
|
+
)
|
278
|
+
end
|
279
|
+
rescue StandardError => e
|
280
|
+
error = e
|
281
|
+
ensure
|
282
|
+
if r.nil? || Utils.error_status?(r.status)
|
283
|
+
r = @sdk_configuration.hooks.after_error(
|
284
|
+
error: error,
|
285
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
286
|
+
hook_ctx: hook_ctx
|
287
|
+
),
|
288
|
+
response: r
|
289
|
+
)
|
290
|
+
else
|
291
|
+
r = @sdk_configuration.hooks.after_success(
|
292
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
293
|
+
hook_ctx: hook_ctx
|
294
|
+
),
|
295
|
+
response: r
|
296
|
+
)
|
297
|
+
end
|
298
|
+
|
299
|
+
if r.nil?
|
300
|
+
raise error if !error.nil?
|
301
|
+
raise 'no response'
|
302
|
+
end
|
150
303
|
end
|
151
304
|
|
152
305
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -175,8 +328,8 @@ module PlexRubySDK
|
|
175
328
|
end
|
176
329
|
|
177
330
|
|
178
|
-
sig { params(playlist_id: ::Float).returns(::PlexRubySDK::Operations::DeletePlaylistResponse) }
|
179
|
-
def delete_playlist(playlist_id)
|
331
|
+
sig { params(playlist_id: ::Float, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::DeletePlaylistResponse) }
|
332
|
+
def delete_playlist(playlist_id, timeout_ms = nil)
|
180
333
|
# delete_playlist - Deletes a Playlist
|
181
334
|
# This endpoint will delete a playlist
|
182
335
|
#
|
@@ -196,10 +349,60 @@ module PlexRubySDK
|
|
196
349
|
headers['Accept'] = 'application/json'
|
197
350
|
headers['user-agent'] = @sdk_configuration.user_agent
|
198
351
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
352
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
353
|
+
|
354
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
355
|
+
timeout ||= @sdk_configuration.timeout
|
356
|
+
|
357
|
+
connection = @sdk_configuration.client
|
358
|
+
|
359
|
+
hook_ctx = SDKHooks::HookContext.new(
|
360
|
+
base_url: base_url,
|
361
|
+
oauth2_scopes: nil,
|
362
|
+
operation_id: 'deletePlaylist',
|
363
|
+
security_source: @sdk_configuration.security_source
|
364
|
+
)
|
365
|
+
|
366
|
+
error = T.let(nil, T.nilable(StandardError))
|
367
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
368
|
+
|
369
|
+
begin
|
370
|
+
r = connection.delete(url) do |req|
|
371
|
+
req.headers.merge!(headers)
|
372
|
+
req.options.timeout = timeout unless timeout.nil?
|
373
|
+
Utils.configure_request_security(req, security)
|
374
|
+
|
375
|
+
@sdk_configuration.hooks.before_request(
|
376
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
377
|
+
hook_ctx: hook_ctx
|
378
|
+
),
|
379
|
+
request: req
|
380
|
+
)
|
381
|
+
end
|
382
|
+
rescue StandardError => e
|
383
|
+
error = e
|
384
|
+
ensure
|
385
|
+
if r.nil? || Utils.error_status?(r.status)
|
386
|
+
r = @sdk_configuration.hooks.after_error(
|
387
|
+
error: error,
|
388
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
389
|
+
hook_ctx: hook_ctx
|
390
|
+
),
|
391
|
+
response: r
|
392
|
+
)
|
393
|
+
else
|
394
|
+
r = @sdk_configuration.hooks.after_success(
|
395
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
396
|
+
hook_ctx: hook_ctx
|
397
|
+
),
|
398
|
+
response: r
|
399
|
+
)
|
400
|
+
end
|
401
|
+
|
402
|
+
if r.nil?
|
403
|
+
raise error if !error.nil?
|
404
|
+
raise 'no response'
|
405
|
+
end
|
203
406
|
end
|
204
407
|
|
205
408
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -224,8 +427,8 @@ module PlexRubySDK
|
|
224
427
|
end
|
225
428
|
|
226
429
|
|
227
|
-
sig { params(playlist_id: ::Float, title: T.nilable(::String), summary: T.nilable(::String)).returns(::PlexRubySDK::Operations::UpdatePlaylistResponse) }
|
228
|
-
def update_playlist(playlist_id, title = nil, summary = nil)
|
430
|
+
sig { params(playlist_id: ::Float, title: T.nilable(::String), summary: T.nilable(::String), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::UpdatePlaylistResponse) }
|
431
|
+
def update_playlist(playlist_id, title = nil, summary = nil, timeout_ms = nil)
|
229
432
|
# update_playlist - Update a Playlist
|
230
433
|
# From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
|
231
434
|
#
|
@@ -248,11 +451,61 @@ module PlexRubySDK
|
|
248
451
|
headers['Accept'] = 'application/json'
|
249
452
|
headers['user-agent'] = @sdk_configuration.user_agent
|
250
453
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
454
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
455
|
+
|
456
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
457
|
+
timeout ||= @sdk_configuration.timeout
|
458
|
+
|
459
|
+
connection = @sdk_configuration.client
|
460
|
+
|
461
|
+
hook_ctx = SDKHooks::HookContext.new(
|
462
|
+
base_url: base_url,
|
463
|
+
oauth2_scopes: nil,
|
464
|
+
operation_id: 'updatePlaylist',
|
465
|
+
security_source: @sdk_configuration.security_source
|
466
|
+
)
|
467
|
+
|
468
|
+
error = T.let(nil, T.nilable(StandardError))
|
469
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
470
|
+
|
471
|
+
begin
|
472
|
+
r = connection.put(url) do |req|
|
473
|
+
req.headers.merge!(headers)
|
474
|
+
req.options.timeout = timeout unless timeout.nil?
|
475
|
+
req.params = query_params
|
476
|
+
Utils.configure_request_security(req, security)
|
477
|
+
|
478
|
+
@sdk_configuration.hooks.before_request(
|
479
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
480
|
+
hook_ctx: hook_ctx
|
481
|
+
),
|
482
|
+
request: req
|
483
|
+
)
|
484
|
+
end
|
485
|
+
rescue StandardError => e
|
486
|
+
error = e
|
487
|
+
ensure
|
488
|
+
if r.nil? || Utils.error_status?(r.status)
|
489
|
+
r = @sdk_configuration.hooks.after_error(
|
490
|
+
error: error,
|
491
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
492
|
+
hook_ctx: hook_ctx
|
493
|
+
),
|
494
|
+
response: r
|
495
|
+
)
|
496
|
+
else
|
497
|
+
r = @sdk_configuration.hooks.after_success(
|
498
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
499
|
+
hook_ctx: hook_ctx
|
500
|
+
),
|
501
|
+
response: r
|
502
|
+
)
|
503
|
+
end
|
504
|
+
|
505
|
+
if r.nil?
|
506
|
+
raise error if !error.nil?
|
507
|
+
raise 'no response'
|
508
|
+
end
|
256
509
|
end
|
257
510
|
|
258
511
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -277,8 +530,8 @@ module PlexRubySDK
|
|
277
530
|
end
|
278
531
|
|
279
532
|
|
280
|
-
sig { params(playlist_id: ::Float, type: ::PlexRubySDK::Operations::GetPlaylistContentsQueryParamType).returns(::PlexRubySDK::Operations::GetPlaylistContentsResponse) }
|
281
|
-
def get_playlist_contents(playlist_id, type)
|
533
|
+
sig { params(playlist_id: ::Float, type: ::PlexRubySDK::Operations::GetPlaylistContentsQueryParamType, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetPlaylistContentsResponse) }
|
534
|
+
def get_playlist_contents(playlist_id, type, timeout_ms = nil)
|
282
535
|
# get_playlist_contents - Retrieve Playlist Contents
|
283
536
|
# Gets the contents of a playlist. Should be paged by clients via standard mechanisms.
|
284
537
|
# By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter.
|
@@ -303,11 +556,61 @@ module PlexRubySDK
|
|
303
556
|
headers['Accept'] = 'application/json'
|
304
557
|
headers['user-agent'] = @sdk_configuration.user_agent
|
305
558
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
559
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
560
|
+
|
561
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
562
|
+
timeout ||= @sdk_configuration.timeout
|
563
|
+
|
564
|
+
connection = @sdk_configuration.client
|
565
|
+
|
566
|
+
hook_ctx = SDKHooks::HookContext.new(
|
567
|
+
base_url: base_url,
|
568
|
+
oauth2_scopes: nil,
|
569
|
+
operation_id: 'getPlaylistContents',
|
570
|
+
security_source: @sdk_configuration.security_source
|
571
|
+
)
|
572
|
+
|
573
|
+
error = T.let(nil, T.nilable(StandardError))
|
574
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
575
|
+
|
576
|
+
begin
|
577
|
+
r = connection.get(url) do |req|
|
578
|
+
req.headers.merge!(headers)
|
579
|
+
req.options.timeout = timeout unless timeout.nil?
|
580
|
+
req.params = query_params
|
581
|
+
Utils.configure_request_security(req, security)
|
582
|
+
|
583
|
+
@sdk_configuration.hooks.before_request(
|
584
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
585
|
+
hook_ctx: hook_ctx
|
586
|
+
),
|
587
|
+
request: req
|
588
|
+
)
|
589
|
+
end
|
590
|
+
rescue StandardError => e
|
591
|
+
error = e
|
592
|
+
ensure
|
593
|
+
if r.nil? || Utils.error_status?(r.status)
|
594
|
+
r = @sdk_configuration.hooks.after_error(
|
595
|
+
error: error,
|
596
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
597
|
+
hook_ctx: hook_ctx
|
598
|
+
),
|
599
|
+
response: r
|
600
|
+
)
|
601
|
+
else
|
602
|
+
r = @sdk_configuration.hooks.after_success(
|
603
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
604
|
+
hook_ctx: hook_ctx
|
605
|
+
),
|
606
|
+
response: r
|
607
|
+
)
|
608
|
+
end
|
609
|
+
|
610
|
+
if r.nil?
|
611
|
+
raise error if !error.nil?
|
612
|
+
raise 'no response'
|
613
|
+
end
|
311
614
|
end
|
312
615
|
|
313
616
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -336,8 +639,8 @@ module PlexRubySDK
|
|
336
639
|
end
|
337
640
|
|
338
641
|
|
339
|
-
sig { params(playlist_id: ::Float).returns(::PlexRubySDK::Operations::ClearPlaylistContentsResponse) }
|
340
|
-
def clear_playlist_contents(playlist_id)
|
642
|
+
sig { params(playlist_id: ::Float, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::ClearPlaylistContentsResponse) }
|
643
|
+
def clear_playlist_contents(playlist_id, timeout_ms = nil)
|
341
644
|
# clear_playlist_contents - Delete Playlist Contents
|
342
645
|
# Clears a playlist, only works with dumb playlists. Returns the playlist.
|
343
646
|
#
|
@@ -357,10 +660,60 @@ module PlexRubySDK
|
|
357
660
|
headers['Accept'] = 'application/json'
|
358
661
|
headers['user-agent'] = @sdk_configuration.user_agent
|
359
662
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
663
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
664
|
+
|
665
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
666
|
+
timeout ||= @sdk_configuration.timeout
|
667
|
+
|
668
|
+
connection = @sdk_configuration.client
|
669
|
+
|
670
|
+
hook_ctx = SDKHooks::HookContext.new(
|
671
|
+
base_url: base_url,
|
672
|
+
oauth2_scopes: nil,
|
673
|
+
operation_id: 'clearPlaylistContents',
|
674
|
+
security_source: @sdk_configuration.security_source
|
675
|
+
)
|
676
|
+
|
677
|
+
error = T.let(nil, T.nilable(StandardError))
|
678
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
679
|
+
|
680
|
+
begin
|
681
|
+
r = connection.delete(url) do |req|
|
682
|
+
req.headers.merge!(headers)
|
683
|
+
req.options.timeout = timeout unless timeout.nil?
|
684
|
+
Utils.configure_request_security(req, security)
|
685
|
+
|
686
|
+
@sdk_configuration.hooks.before_request(
|
687
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
688
|
+
hook_ctx: hook_ctx
|
689
|
+
),
|
690
|
+
request: req
|
691
|
+
)
|
692
|
+
end
|
693
|
+
rescue StandardError => e
|
694
|
+
error = e
|
695
|
+
ensure
|
696
|
+
if r.nil? || Utils.error_status?(r.status)
|
697
|
+
r = @sdk_configuration.hooks.after_error(
|
698
|
+
error: error,
|
699
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
700
|
+
hook_ctx: hook_ctx
|
701
|
+
),
|
702
|
+
response: r
|
703
|
+
)
|
704
|
+
else
|
705
|
+
r = @sdk_configuration.hooks.after_success(
|
706
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
707
|
+
hook_ctx: hook_ctx
|
708
|
+
),
|
709
|
+
response: r
|
710
|
+
)
|
711
|
+
end
|
712
|
+
|
713
|
+
if r.nil?
|
714
|
+
raise error if !error.nil?
|
715
|
+
raise 'no response'
|
716
|
+
end
|
364
717
|
end
|
365
718
|
|
366
719
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -385,8 +738,8 @@ module PlexRubySDK
|
|
385
738
|
end
|
386
739
|
|
387
740
|
|
388
|
-
sig { params(playlist_id: ::Float, uri: ::String, play_queue_id: T.nilable(::Float)).returns(::PlexRubySDK::Operations::AddPlaylistContentsResponse) }
|
389
|
-
def add_playlist_contents(playlist_id, uri, play_queue_id = nil)
|
741
|
+
sig { params(playlist_id: ::Float, uri: ::String, play_queue_id: T.nilable(::Float), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::AddPlaylistContentsResponse) }
|
742
|
+
def add_playlist_contents(playlist_id, uri, play_queue_id = nil, timeout_ms = nil)
|
390
743
|
# add_playlist_contents - Adding to a Playlist
|
391
744
|
# Adds a generator to a playlist, same parameters as the POST to create. With a dumb playlist, this adds the specified items to the playlist.
|
392
745
|
# With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
|
@@ -410,11 +763,61 @@ module PlexRubySDK
|
|
410
763
|
headers['Accept'] = 'application/json'
|
411
764
|
headers['user-agent'] = @sdk_configuration.user_agent
|
412
765
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
766
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
767
|
+
|
768
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
769
|
+
timeout ||= @sdk_configuration.timeout
|
770
|
+
|
771
|
+
connection = @sdk_configuration.client
|
772
|
+
|
773
|
+
hook_ctx = SDKHooks::HookContext.new(
|
774
|
+
base_url: base_url,
|
775
|
+
oauth2_scopes: nil,
|
776
|
+
operation_id: 'addPlaylistContents',
|
777
|
+
security_source: @sdk_configuration.security_source
|
778
|
+
)
|
779
|
+
|
780
|
+
error = T.let(nil, T.nilable(StandardError))
|
781
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
782
|
+
|
783
|
+
begin
|
784
|
+
r = connection.put(url) do |req|
|
785
|
+
req.headers.merge!(headers)
|
786
|
+
req.options.timeout = timeout unless timeout.nil?
|
787
|
+
req.params = query_params
|
788
|
+
Utils.configure_request_security(req, security)
|
789
|
+
|
790
|
+
@sdk_configuration.hooks.before_request(
|
791
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
792
|
+
hook_ctx: hook_ctx
|
793
|
+
),
|
794
|
+
request: req
|
795
|
+
)
|
796
|
+
end
|
797
|
+
rescue StandardError => e
|
798
|
+
error = e
|
799
|
+
ensure
|
800
|
+
if r.nil? || Utils.error_status?(r.status)
|
801
|
+
r = @sdk_configuration.hooks.after_error(
|
802
|
+
error: error,
|
803
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
804
|
+
hook_ctx: hook_ctx
|
805
|
+
),
|
806
|
+
response: r
|
807
|
+
)
|
808
|
+
else
|
809
|
+
r = @sdk_configuration.hooks.after_success(
|
810
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
811
|
+
hook_ctx: hook_ctx
|
812
|
+
),
|
813
|
+
response: r
|
814
|
+
)
|
815
|
+
end
|
816
|
+
|
817
|
+
if r.nil?
|
818
|
+
raise error if !error.nil?
|
819
|
+
raise 'no response'
|
820
|
+
end
|
418
821
|
end
|
419
822
|
|
420
823
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -443,8 +846,8 @@ module PlexRubySDK
|
|
443
846
|
end
|
444
847
|
|
445
848
|
|
446
|
-
sig { params(path: ::String, force: ::PlexRubySDK::Operations::QueryParamForce, section_id: ::Integer).returns(::PlexRubySDK::Operations::UploadPlaylistResponse) }
|
447
|
-
def upload_playlist(path, force, section_id)
|
849
|
+
sig { params(path: ::String, force: ::PlexRubySDK::Operations::QueryParamForce, section_id: ::Integer, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::UploadPlaylistResponse) }
|
850
|
+
def upload_playlist(path, force, section_id, timeout_ms = nil)
|
448
851
|
# upload_playlist - Upload Playlist
|
449
852
|
# Imports m3u playlists by passing a path on the server to scan for m3u-formatted playlist files, or a path to a single playlist file.
|
450
853
|
#
|
@@ -462,11 +865,61 @@ module PlexRubySDK
|
|
462
865
|
headers['Accept'] = 'application/json'
|
463
866
|
headers['user-agent'] = @sdk_configuration.user_agent
|
464
867
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
868
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
869
|
+
|
870
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
871
|
+
timeout ||= @sdk_configuration.timeout
|
872
|
+
|
873
|
+
connection = @sdk_configuration.client
|
874
|
+
|
875
|
+
hook_ctx = SDKHooks::HookContext.new(
|
876
|
+
base_url: base_url,
|
877
|
+
oauth2_scopes: nil,
|
878
|
+
operation_id: 'uploadPlaylist',
|
879
|
+
security_source: @sdk_configuration.security_source
|
880
|
+
)
|
881
|
+
|
882
|
+
error = T.let(nil, T.nilable(StandardError))
|
883
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
884
|
+
|
885
|
+
begin
|
886
|
+
r = connection.post(url) do |req|
|
887
|
+
req.headers.merge!(headers)
|
888
|
+
req.options.timeout = timeout unless timeout.nil?
|
889
|
+
req.params = query_params
|
890
|
+
Utils.configure_request_security(req, security)
|
891
|
+
|
892
|
+
@sdk_configuration.hooks.before_request(
|
893
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
894
|
+
hook_ctx: hook_ctx
|
895
|
+
),
|
896
|
+
request: req
|
897
|
+
)
|
898
|
+
end
|
899
|
+
rescue StandardError => e
|
900
|
+
error = e
|
901
|
+
ensure
|
902
|
+
if r.nil? || Utils.error_status?(r.status)
|
903
|
+
r = @sdk_configuration.hooks.after_error(
|
904
|
+
error: error,
|
905
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
906
|
+
hook_ctx: hook_ctx
|
907
|
+
),
|
908
|
+
response: r
|
909
|
+
)
|
910
|
+
else
|
911
|
+
r = @sdk_configuration.hooks.after_success(
|
912
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
913
|
+
hook_ctx: hook_ctx
|
914
|
+
),
|
915
|
+
response: r
|
916
|
+
)
|
917
|
+
end
|
918
|
+
|
919
|
+
if r.nil?
|
920
|
+
raise error if !error.nil?
|
921
|
+
raise 'no response'
|
922
|
+
end
|
470
923
|
end
|
471
924
|
|
472
925
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|