plex-api-client 0.6.1__py3-none-any.whl
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.
- plex_api/__init__.py +4 -0
- plex_api/_hooks/__init__.py +5 -0
- plex_api/_hooks/registration.py +13 -0
- plex_api/_hooks/sdkhooks.py +57 -0
- plex_api/_hooks/types.py +74 -0
- plex_api/activities.py +151 -0
- plex_api/authentication.py +146 -0
- plex_api/butler.py +333 -0
- plex_api/hubs.py +158 -0
- plex_api/library.py +808 -0
- plex_api/log.py +225 -0
- plex_api/media.py +210 -0
- plex_api/models/__init__.py +4 -0
- plex_api/models/components/__init__.py +5 -0
- plex_api/models/components/security.py +11 -0
- plex_api/models/errors/__init__.py +63 -0
- plex_api/models/errors/addplaylistcontents.py +32 -0
- plex_api/models/errors/applyupdates.py +32 -0
- plex_api/models/errors/cancelserveractivities.py +32 -0
- plex_api/models/errors/checkforupdates.py +32 -0
- plex_api/models/errors/clearplaylistcontents.py +32 -0
- plex_api/models/errors/createplaylist.py +32 -0
- plex_api/models/errors/deletelibrary.py +32 -0
- plex_api/models/errors/deleteplaylist.py +32 -0
- plex_api/models/errors/enablepapertrail.py +32 -0
- plex_api/models/errors/getavailableclients.py +32 -0
- plex_api/models/errors/getbutlertasks.py +32 -0
- plex_api/models/errors/getdevices.py +32 -0
- plex_api/models/errors/getfilehash.py +32 -0
- plex_api/models/errors/getglobalhubs.py +32 -0
- plex_api/models/errors/getlibraries.py +32 -0
- plex_api/models/errors/getlibrary.py +32 -0
- plex_api/models/errors/getlibraryhubs.py +32 -0
- plex_api/models/errors/getmetadata.py +32 -0
- plex_api/models/errors/getmetadatachildren.py +32 -0
- plex_api/models/errors/getmyplexaccount.py +32 -0
- plex_api/models/errors/getondeck.py +32 -0
- plex_api/models/errors/getpin.py +32 -0
- plex_api/models/errors/getplaylist.py +32 -0
- plex_api/models/errors/getplaylistcontents.py +32 -0
- plex_api/models/errors/getplaylists.py +32 -0
- plex_api/models/errors/getrecentlyadded.py +32 -0
- plex_api/models/errors/getresizedphoto.py +32 -0
- plex_api/models/errors/getsearchresults.py +32 -0
- plex_api/models/errors/getserveractivities.py +32 -0
- plex_api/models/errors/getservercapabilities.py +32 -0
- plex_api/models/errors/getserveridentity.py +32 -0
- plex_api/models/errors/getserverlist.py +32 -0
- plex_api/models/errors/getserverpreferences.py +32 -0
- plex_api/models/errors/getsessionhistory.py +32 -0
- plex_api/models/errors/getsessions.py +32 -0
- plex_api/models/errors/getsourceconnectioninformation.py +32 -0
- plex_api/models/errors/getstatistics.py +32 -0
- plex_api/models/errors/gettimeline.py +32 -0
- plex_api/models/errors/gettoken.py +32 -0
- plex_api/models/errors/gettranscodesessions.py +32 -0
- plex_api/models/errors/gettransienttoken.py +32 -0
- plex_api/models/errors/getupdatestatus.py +32 -0
- plex_api/models/errors/logline.py +32 -0
- plex_api/models/errors/logmultiline.py +32 -0
- plex_api/models/errors/markplayed.py +32 -0
- plex_api/models/errors/markunplayed.py +32 -0
- plex_api/models/errors/performsearch.py +32 -0
- plex_api/models/errors/performvoicesearch.py +32 -0
- plex_api/models/errors/refreshlibrary.py +32 -0
- plex_api/models/errors/sdkerror.py +24 -0
- plex_api/models/errors/startalltasks.py +32 -0
- plex_api/models/errors/starttask.py +32 -0
- plex_api/models/errors/startuniversaltranscode.py +32 -0
- plex_api/models/errors/stopalltasks.py +32 -0
- plex_api/models/errors/stoptask.py +32 -0
- plex_api/models/errors/stoptranscodesession.py +32 -0
- plex_api/models/errors/updateplaylist.py +32 -0
- plex_api/models/errors/updateplayprogress.py +32 -0
- plex_api/models/errors/uploadplaylist.py +32 -0
- plex_api/models/operations/__init__.py +64 -0
- plex_api/models/operations/addplaylistcontents.py +74 -0
- plex_api/models/operations/applyupdates.py +39 -0
- plex_api/models/operations/cancelserveractivities.py +25 -0
- plex_api/models/operations/checkforupdates.py +32 -0
- plex_api/models/operations/clearplaylistcontents.py +25 -0
- plex_api/models/operations/createplaylist.py +91 -0
- plex_api/models/operations/deletelibrary.py +25 -0
- plex_api/models/operations/deleteplaylist.py +25 -0
- plex_api/models/operations/enablepapertrail.py +17 -0
- plex_api/models/operations/getavailableclients.py +58 -0
- plex_api/models/operations/getbutlertasks.py +52 -0
- plex_api/models/operations/getdevices.py +53 -0
- plex_api/models/operations/getfilehash.py +28 -0
- plex_api/models/operations/getglobalhubs.py +100 -0
- plex_api/models/operations/getlibraries.py +79 -0
- plex_api/models/operations/getlibrary.py +153 -0
- plex_api/models/operations/getlibraryhubs.py +205 -0
- plex_api/models/operations/getlibraryitems.py +227 -0
- plex_api/models/operations/getmetadata.py +264 -0
- plex_api/models/operations/getmetadatachildren.py +115 -0
- plex_api/models/operations/getmyplexaccount.py +50 -0
- plex_api/models/operations/getondeck.py +166 -0
- plex_api/models/operations/getpin.py +86 -0
- plex_api/models/operations/getplaylist.py +70 -0
- plex_api/models/operations/getplaylistcontents.py +178 -0
- plex_api/models/operations/getplaylists.py +85 -0
- plex_api/models/operations/getrecentlyadded.py +166 -0
- plex_api/models/operations/getresizedphoto.py +48 -0
- plex_api/models/operations/getsearchresults.py +182 -0
- plex_api/models/operations/getserveractivities.py +63 -0
- plex_api/models/operations/getservercapabilities.py +99 -0
- plex_api/models/operations/getserveridentity.py +42 -0
- plex_api/models/operations/getserverlist.py +53 -0
- plex_api/models/operations/getserverpreferences.py +57 -0
- plex_api/models/operations/getsessionhistory.py +67 -0
- plex_api/models/operations/getsessions.py +185 -0
- plex_api/models/operations/getsourceconnectioninformation.py +25 -0
- plex_api/models/operations/getstatistics.py +93 -0
- plex_api/models/operations/gettimeline.py +50 -0
- plex_api/models/operations/gettoken.py +35 -0
- plex_api/models/operations/gettranscodesessions.py +71 -0
- plex_api/models/operations/gettransienttoken.py +36 -0
- plex_api/models/operations/getupdatestatus.py +57 -0
- plex_api/models/operations/logline.py +50 -0
- plex_api/models/operations/logmultiline.py +17 -0
- plex_api/models/operations/markplayed.py +25 -0
- plex_api/models/operations/markunplayed.py +25 -0
- plex_api/models/operations/performsearch.py +30 -0
- plex_api/models/operations/performvoicesearch.py +30 -0
- plex_api/models/operations/refreshlibrary.py +25 -0
- plex_api/models/operations/searchlibrary.py +96 -0
- plex_api/models/operations/startalltasks.py +17 -0
- plex_api/models/operations/starttask.py +43 -0
- plex_api/models/operations/startuniversaltranscode.py +56 -0
- plex_api/models/operations/stopalltasks.py +17 -0
- plex_api/models/operations/stoptask.py +43 -0
- plex_api/models/operations/stoptranscodesession.py +25 -0
- plex_api/models/operations/updateplaylist.py +30 -0
- plex_api/models/operations/updateplayprogress.py +29 -0
- plex_api/models/operations/uploadplaylist.py +47 -0
- plex_api/playlists.py +629 -0
- plex_api/plex.py +154 -0
- plex_api/sdk.py +180 -0
- plex_api/sdkconfiguration.py +52 -0
- plex_api/search.py +232 -0
- plex_api/server.py +525 -0
- plex_api/sessions.py +272 -0
- plex_api/statistics.py +86 -0
- plex_api/updater.py +212 -0
- plex_api/utils/__init__.py +4 -0
- plex_api/utils/retries.py +120 -0
- plex_api/utils/utils.py +898 -0
- plex_api/video.py +136 -0
- plex_api_client-0.6.1.dist-info/LICENSE.md +21 -0
- plex_api_client-0.6.1.dist-info/METADATA +397 -0
- plex_api_client-0.6.1.dist-info/RECORD +154 -0
- plex_api_client-0.6.1.dist-info/WHEEL +5 -0
- plex_api_client-0.6.1.dist-info/top_level.txt +1 -0
plex_api/butler.py
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
import requests as requests_http
|
|
4
|
+
from .sdkconfiguration import SDKConfiguration
|
|
5
|
+
from plex_api import utils
|
|
6
|
+
from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
|
|
7
|
+
from plex_api.models import errors, operations
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
class Butler:
|
|
11
|
+
r"""Butler is the task manager of the Plex Media Server Ecosystem."""
|
|
12
|
+
sdk_configuration: SDKConfiguration
|
|
13
|
+
|
|
14
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
|
15
|
+
self.sdk_configuration = sdk_config
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_butler_tasks(self) -> operations.GetButlerTasksResponse:
|
|
20
|
+
r"""Get Butler tasks
|
|
21
|
+
Returns a list of butler tasks
|
|
22
|
+
"""
|
|
23
|
+
hook_ctx = HookContext(operation_id='getButlerTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
24
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
25
|
+
|
|
26
|
+
url = base_url + '/butler'
|
|
27
|
+
|
|
28
|
+
if callable(self.sdk_configuration.security):
|
|
29
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
30
|
+
else:
|
|
31
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
32
|
+
|
|
33
|
+
headers['Accept'] = 'application/json'
|
|
34
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
35
|
+
client = self.sdk_configuration.client
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
39
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
40
|
+
http_res = client.send(req)
|
|
41
|
+
except Exception as e:
|
|
42
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
43
|
+
if e is not None:
|
|
44
|
+
raise e
|
|
45
|
+
|
|
46
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
47
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
48
|
+
if e is not None:
|
|
49
|
+
raise e
|
|
50
|
+
if result is not None:
|
|
51
|
+
http_res = result
|
|
52
|
+
else:
|
|
53
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
res = operations.GetButlerTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
58
|
+
|
|
59
|
+
if http_res.status_code == 200:
|
|
60
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
61
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetButlerTasksResponseBody])
|
|
62
|
+
res.object = out
|
|
63
|
+
else:
|
|
64
|
+
content_type = http_res.headers.get('Content-Type')
|
|
65
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
66
|
+
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
67
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
68
|
+
elif http_res.status_code == 401:
|
|
69
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
70
|
+
out = utils.unmarshal_json(http_res.text, errors.GetButlerTasksResponseBody)
|
|
71
|
+
out.raw_response = http_res
|
|
72
|
+
raise out
|
|
73
|
+
else:
|
|
74
|
+
content_type = http_res.headers.get('Content-Type')
|
|
75
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
76
|
+
else:
|
|
77
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
78
|
+
|
|
79
|
+
return res
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def start_all_tasks(self) -> operations.StartAllTasksResponse:
|
|
84
|
+
r"""Start all Butler tasks
|
|
85
|
+
This endpoint will attempt to start all Butler tasks that are enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
|
|
86
|
+
1. Any tasks not scheduled to run on the current day will be skipped.
|
|
87
|
+
2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
|
|
88
|
+
3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
|
|
89
|
+
4. If we are outside the configured window, the task will start immediately.
|
|
90
|
+
"""
|
|
91
|
+
hook_ctx = HookContext(operation_id='startAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
92
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
93
|
+
|
|
94
|
+
url = base_url + '/butler'
|
|
95
|
+
|
|
96
|
+
if callable(self.sdk_configuration.security):
|
|
97
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
98
|
+
else:
|
|
99
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
100
|
+
|
|
101
|
+
headers['Accept'] = 'application/json'
|
|
102
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
103
|
+
client = self.sdk_configuration.client
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
|
|
107
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
108
|
+
http_res = client.send(req)
|
|
109
|
+
except Exception as e:
|
|
110
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
111
|
+
if e is not None:
|
|
112
|
+
raise e
|
|
113
|
+
|
|
114
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
115
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
116
|
+
if e is not None:
|
|
117
|
+
raise e
|
|
118
|
+
if result is not None:
|
|
119
|
+
http_res = result
|
|
120
|
+
else:
|
|
121
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
res = operations.StartAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
126
|
+
|
|
127
|
+
if http_res.status_code == 200:
|
|
128
|
+
pass
|
|
129
|
+
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
130
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
131
|
+
elif http_res.status_code == 401:
|
|
132
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
133
|
+
out = utils.unmarshal_json(http_res.text, errors.StartAllTasksResponseBody)
|
|
134
|
+
out.raw_response = http_res
|
|
135
|
+
raise out
|
|
136
|
+
else:
|
|
137
|
+
content_type = http_res.headers.get('Content-Type')
|
|
138
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
139
|
+
else:
|
|
140
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
141
|
+
|
|
142
|
+
return res
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def stop_all_tasks(self) -> operations.StopAllTasksResponse:
|
|
147
|
+
r"""Stop all Butler tasks
|
|
148
|
+
This endpoint will stop all currently running tasks and remove any scheduled tasks from the queue.
|
|
149
|
+
"""
|
|
150
|
+
hook_ctx = HookContext(operation_id='stopAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
151
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
152
|
+
|
|
153
|
+
url = base_url + '/butler'
|
|
154
|
+
|
|
155
|
+
if callable(self.sdk_configuration.security):
|
|
156
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
157
|
+
else:
|
|
158
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
159
|
+
|
|
160
|
+
headers['Accept'] = 'application/json'
|
|
161
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
162
|
+
client = self.sdk_configuration.client
|
|
163
|
+
|
|
164
|
+
try:
|
|
165
|
+
req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
|
|
166
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
167
|
+
http_res = client.send(req)
|
|
168
|
+
except Exception as e:
|
|
169
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
170
|
+
if e is not None:
|
|
171
|
+
raise e
|
|
172
|
+
|
|
173
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
174
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
175
|
+
if e is not None:
|
|
176
|
+
raise e
|
|
177
|
+
if result is not None:
|
|
178
|
+
http_res = result
|
|
179
|
+
else:
|
|
180
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
res = operations.StopAllTasksResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
185
|
+
|
|
186
|
+
if http_res.status_code == 200:
|
|
187
|
+
pass
|
|
188
|
+
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
189
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
190
|
+
elif http_res.status_code == 401:
|
|
191
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
192
|
+
out = utils.unmarshal_json(http_res.text, errors.StopAllTasksResponseBody)
|
|
193
|
+
out.raw_response = http_res
|
|
194
|
+
raise out
|
|
195
|
+
else:
|
|
196
|
+
content_type = http_res.headers.get('Content-Type')
|
|
197
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
198
|
+
else:
|
|
199
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
200
|
+
|
|
201
|
+
return res
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def start_task(self, task_name: operations.TaskName) -> operations.StartTaskResponse:
|
|
206
|
+
r"""Start a single Butler task
|
|
207
|
+
This endpoint will attempt to start a single Butler task that is enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
|
|
208
|
+
1. Any tasks not scheduled to run on the current day will be skipped.
|
|
209
|
+
2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
|
|
210
|
+
3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
|
|
211
|
+
4. If we are outside the configured window, the task will start immediately.
|
|
212
|
+
"""
|
|
213
|
+
hook_ctx = HookContext(operation_id='startTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
214
|
+
request = operations.StartTaskRequest(
|
|
215
|
+
task_name=task_name,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
219
|
+
|
|
220
|
+
url = utils.generate_url(operations.StartTaskRequest, base_url, '/butler/{taskName}', request, self.sdk_configuration.globals)
|
|
221
|
+
|
|
222
|
+
if callable(self.sdk_configuration.security):
|
|
223
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
224
|
+
else:
|
|
225
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
226
|
+
|
|
227
|
+
headers['Accept'] = 'application/json'
|
|
228
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
229
|
+
client = self.sdk_configuration.client
|
|
230
|
+
|
|
231
|
+
try:
|
|
232
|
+
req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
|
|
233
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
234
|
+
http_res = client.send(req)
|
|
235
|
+
except Exception as e:
|
|
236
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
237
|
+
if e is not None:
|
|
238
|
+
raise e
|
|
239
|
+
|
|
240
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
241
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
242
|
+
if e is not None:
|
|
243
|
+
raise e
|
|
244
|
+
if result is not None:
|
|
245
|
+
http_res = result
|
|
246
|
+
else:
|
|
247
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
res = operations.StartTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
252
|
+
|
|
253
|
+
if http_res.status_code in [200, 202]:
|
|
254
|
+
pass
|
|
255
|
+
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
256
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
257
|
+
elif http_res.status_code == 401:
|
|
258
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
259
|
+
out = utils.unmarshal_json(http_res.text, errors.StartTaskResponseBody)
|
|
260
|
+
out.raw_response = http_res
|
|
261
|
+
raise out
|
|
262
|
+
else:
|
|
263
|
+
content_type = http_res.headers.get('Content-Type')
|
|
264
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
265
|
+
else:
|
|
266
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
267
|
+
|
|
268
|
+
return res
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def stop_task(self, task_name: operations.PathParamTaskName) -> operations.StopTaskResponse:
|
|
273
|
+
r"""Stop a single Butler task
|
|
274
|
+
This endpoint will stop a currently running task by name, or remove it from the list of scheduled tasks if it exists. See the section above for a list of task names for this endpoint.
|
|
275
|
+
"""
|
|
276
|
+
hook_ctx = HookContext(operation_id='stopTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
277
|
+
request = operations.StopTaskRequest(
|
|
278
|
+
task_name=task_name,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
282
|
+
|
|
283
|
+
url = utils.generate_url(operations.StopTaskRequest, base_url, '/butler/{taskName}', request, self.sdk_configuration.globals)
|
|
284
|
+
|
|
285
|
+
if callable(self.sdk_configuration.security):
|
|
286
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
287
|
+
else:
|
|
288
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
289
|
+
|
|
290
|
+
headers['Accept'] = 'application/json'
|
|
291
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
292
|
+
client = self.sdk_configuration.client
|
|
293
|
+
|
|
294
|
+
try:
|
|
295
|
+
req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
|
|
296
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
297
|
+
http_res = client.send(req)
|
|
298
|
+
except Exception as e:
|
|
299
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
300
|
+
if e is not None:
|
|
301
|
+
raise e
|
|
302
|
+
|
|
303
|
+
if utils.match_status_codes(['400','401','404','4XX','5XX'], http_res.status_code):
|
|
304
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
305
|
+
if e is not None:
|
|
306
|
+
raise e
|
|
307
|
+
if result is not None:
|
|
308
|
+
http_res = result
|
|
309
|
+
else:
|
|
310
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
res = operations.StopTaskResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
315
|
+
|
|
316
|
+
if http_res.status_code == 200:
|
|
317
|
+
pass
|
|
318
|
+
elif http_res.status_code == 400 or http_res.status_code == 404 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
319
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
320
|
+
elif http_res.status_code == 401:
|
|
321
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
322
|
+
out = utils.unmarshal_json(http_res.text, errors.StopTaskResponseBody)
|
|
323
|
+
out.raw_response = http_res
|
|
324
|
+
raise out
|
|
325
|
+
else:
|
|
326
|
+
content_type = http_res.headers.get('Content-Type')
|
|
327
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
328
|
+
else:
|
|
329
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
330
|
+
|
|
331
|
+
return res
|
|
332
|
+
|
|
333
|
+
|
plex_api/hubs.py
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
import requests as requests_http
|
|
4
|
+
from .sdkconfiguration import SDKConfiguration
|
|
5
|
+
from plex_api import utils
|
|
6
|
+
from plex_api._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext
|
|
7
|
+
from plex_api.models import errors, operations
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
class Hubs:
|
|
11
|
+
r"""Hubs are a structured two-dimensional container for media, generally represented by multiple horizontal rows."""
|
|
12
|
+
sdk_configuration: SDKConfiguration
|
|
13
|
+
|
|
14
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
|
15
|
+
self.sdk_configuration = sdk_config
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_global_hubs(self, count: Optional[float] = None, only_transient: Optional[operations.OnlyTransient] = None) -> operations.GetGlobalHubsResponse:
|
|
20
|
+
r"""Get Global Hubs
|
|
21
|
+
Get Global Hubs filtered by the parameters provided.
|
|
22
|
+
"""
|
|
23
|
+
hook_ctx = HookContext(operation_id='getGlobalHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
24
|
+
request = operations.GetGlobalHubsRequest(
|
|
25
|
+
count=count,
|
|
26
|
+
only_transient=only_transient,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
30
|
+
|
|
31
|
+
url = base_url + '/hubs'
|
|
32
|
+
|
|
33
|
+
if callable(self.sdk_configuration.security):
|
|
34
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
35
|
+
else:
|
|
36
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
37
|
+
|
|
38
|
+
query_params = { **utils.get_query_params(operations.GetGlobalHubsRequest, request, self.sdk_configuration.globals), **query_params }
|
|
39
|
+
headers['Accept'] = 'application/json'
|
|
40
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
41
|
+
client = self.sdk_configuration.client
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
45
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
46
|
+
http_res = client.send(req)
|
|
47
|
+
except Exception as e:
|
|
48
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
49
|
+
if e is not None:
|
|
50
|
+
raise e
|
|
51
|
+
|
|
52
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
53
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
54
|
+
if e is not None:
|
|
55
|
+
raise e
|
|
56
|
+
if result is not None:
|
|
57
|
+
http_res = result
|
|
58
|
+
else:
|
|
59
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
res = operations.GetGlobalHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
64
|
+
|
|
65
|
+
if http_res.status_code == 200:
|
|
66
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
67
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetGlobalHubsResponseBody])
|
|
68
|
+
res.object = out
|
|
69
|
+
else:
|
|
70
|
+
content_type = http_res.headers.get('Content-Type')
|
|
71
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
72
|
+
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
73
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
74
|
+
elif http_res.status_code == 401:
|
|
75
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
76
|
+
out = utils.unmarshal_json(http_res.text, errors.GetGlobalHubsResponseBody)
|
|
77
|
+
out.raw_response = http_res
|
|
78
|
+
raise out
|
|
79
|
+
else:
|
|
80
|
+
content_type = http_res.headers.get('Content-Type')
|
|
81
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
82
|
+
else:
|
|
83
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
84
|
+
|
|
85
|
+
return res
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def get_library_hubs(self, section_id: float, count: Optional[float] = None, only_transient: Optional[operations.QueryParamOnlyTransient] = None) -> operations.GetLibraryHubsResponse:
|
|
90
|
+
r"""Get library specific hubs
|
|
91
|
+
This endpoint will return a list of library specific hubs
|
|
92
|
+
"""
|
|
93
|
+
hook_ctx = HookContext(operation_id='getLibraryHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
94
|
+
request = operations.GetLibraryHubsRequest(
|
|
95
|
+
section_id=section_id,
|
|
96
|
+
count=count,
|
|
97
|
+
only_transient=only_transient,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
101
|
+
|
|
102
|
+
url = utils.generate_url(operations.GetLibraryHubsRequest, base_url, '/hubs/sections/{sectionId}', request, self.sdk_configuration.globals)
|
|
103
|
+
|
|
104
|
+
if callable(self.sdk_configuration.security):
|
|
105
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
106
|
+
else:
|
|
107
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
108
|
+
|
|
109
|
+
query_params = { **utils.get_query_params(operations.GetLibraryHubsRequest, request, self.sdk_configuration.globals), **query_params }
|
|
110
|
+
headers['Accept'] = 'application/json'
|
|
111
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
112
|
+
client = self.sdk_configuration.client
|
|
113
|
+
|
|
114
|
+
try:
|
|
115
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
116
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
117
|
+
http_res = client.send(req)
|
|
118
|
+
except Exception as e:
|
|
119
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
120
|
+
if e is not None:
|
|
121
|
+
raise e
|
|
122
|
+
|
|
123
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
124
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
125
|
+
if e is not None:
|
|
126
|
+
raise e
|
|
127
|
+
if result is not None:
|
|
128
|
+
http_res = result
|
|
129
|
+
else:
|
|
130
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
res = operations.GetLibraryHubsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
135
|
+
|
|
136
|
+
if http_res.status_code == 200:
|
|
137
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
138
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetLibraryHubsResponseBody])
|
|
139
|
+
res.object = out
|
|
140
|
+
else:
|
|
141
|
+
content_type = http_res.headers.get('Content-Type')
|
|
142
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
143
|
+
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
144
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
145
|
+
elif http_res.status_code == 401:
|
|
146
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
147
|
+
out = utils.unmarshal_json(http_res.text, errors.GetLibraryHubsResponseBody)
|
|
148
|
+
out.raw_response = http_res
|
|
149
|
+
raise out
|
|
150
|
+
else:
|
|
151
|
+
content_type = http_res.headers.get('Content-Type')
|
|
152
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
153
|
+
else:
|
|
154
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
155
|
+
|
|
156
|
+
return res
|
|
157
|
+
|
|
158
|
+
|