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/sessions.py
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
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 Sessions:
|
|
11
|
+
r"""API Calls that perform search operations with Plex Media Server Sessions"""
|
|
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_sessions(self) -> operations.GetSessionsResponse:
|
|
20
|
+
r"""Get Active Sessions
|
|
21
|
+
This will retrieve the \"Now Playing\" Information of the PMS.
|
|
22
|
+
"""
|
|
23
|
+
hook_ctx = HookContext(operation_id='getSessions', 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 + '/status/sessions'
|
|
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.GetSessionsResponse(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.GetSessionsResponseBody])
|
|
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.GetSessionsResponseBody)
|
|
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 get_session_history(self) -> operations.GetSessionHistoryResponse:
|
|
84
|
+
r"""Get Session History
|
|
85
|
+
This will Retrieve a listing of all history views.
|
|
86
|
+
"""
|
|
87
|
+
hook_ctx = HookContext(operation_id='getSessionHistory', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
88
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
89
|
+
|
|
90
|
+
url = base_url + '/status/sessions/history/all'
|
|
91
|
+
|
|
92
|
+
if callable(self.sdk_configuration.security):
|
|
93
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
94
|
+
else:
|
|
95
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
96
|
+
|
|
97
|
+
headers['Accept'] = 'application/json'
|
|
98
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
99
|
+
client = self.sdk_configuration.client
|
|
100
|
+
|
|
101
|
+
try:
|
|
102
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
103
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
104
|
+
http_res = client.send(req)
|
|
105
|
+
except Exception as e:
|
|
106
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
107
|
+
if e is not None:
|
|
108
|
+
raise e
|
|
109
|
+
|
|
110
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
111
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
112
|
+
if e is not None:
|
|
113
|
+
raise e
|
|
114
|
+
if result is not None:
|
|
115
|
+
http_res = result
|
|
116
|
+
else:
|
|
117
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
res = operations.GetSessionHistoryResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
122
|
+
|
|
123
|
+
if http_res.status_code == 200:
|
|
124
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
125
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetSessionHistoryResponseBody])
|
|
126
|
+
res.object = out
|
|
127
|
+
else:
|
|
128
|
+
content_type = http_res.headers.get('Content-Type')
|
|
129
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
130
|
+
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:
|
|
131
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
132
|
+
elif http_res.status_code == 401:
|
|
133
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
134
|
+
out = utils.unmarshal_json(http_res.text, errors.GetSessionHistoryResponseBody)
|
|
135
|
+
out.raw_response = http_res
|
|
136
|
+
raise out
|
|
137
|
+
else:
|
|
138
|
+
content_type = http_res.headers.get('Content-Type')
|
|
139
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
140
|
+
else:
|
|
141
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
142
|
+
|
|
143
|
+
return res
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def get_transcode_sessions(self) -> operations.GetTranscodeSessionsResponse:
|
|
148
|
+
r"""Get Transcode Sessions
|
|
149
|
+
Get Transcode Sessions
|
|
150
|
+
"""
|
|
151
|
+
hook_ctx = HookContext(operation_id='getTranscodeSessions', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
152
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
153
|
+
|
|
154
|
+
url = base_url + '/transcode/sessions'
|
|
155
|
+
|
|
156
|
+
if callable(self.sdk_configuration.security):
|
|
157
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
158
|
+
else:
|
|
159
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
160
|
+
|
|
161
|
+
headers['Accept'] = 'application/json'
|
|
162
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
163
|
+
client = self.sdk_configuration.client
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
167
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
168
|
+
http_res = client.send(req)
|
|
169
|
+
except Exception as e:
|
|
170
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
171
|
+
if e is not None:
|
|
172
|
+
raise e
|
|
173
|
+
|
|
174
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
175
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
176
|
+
if e is not None:
|
|
177
|
+
raise e
|
|
178
|
+
if result is not None:
|
|
179
|
+
http_res = result
|
|
180
|
+
else:
|
|
181
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
res = operations.GetTranscodeSessionsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
186
|
+
|
|
187
|
+
if http_res.status_code == 200:
|
|
188
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
189
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetTranscodeSessionsResponseBody])
|
|
190
|
+
res.object = out
|
|
191
|
+
else:
|
|
192
|
+
content_type = http_res.headers.get('Content-Type')
|
|
193
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
194
|
+
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:
|
|
195
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
196
|
+
elif http_res.status_code == 401:
|
|
197
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
198
|
+
out = utils.unmarshal_json(http_res.text, errors.GetTranscodeSessionsResponseBody)
|
|
199
|
+
out.raw_response = http_res
|
|
200
|
+
raise out
|
|
201
|
+
else:
|
|
202
|
+
content_type = http_res.headers.get('Content-Type')
|
|
203
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
204
|
+
else:
|
|
205
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
206
|
+
|
|
207
|
+
return res
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def stop_transcode_session(self, session_key: str) -> operations.StopTranscodeSessionResponse:
|
|
212
|
+
r"""Stop a Transcode Session
|
|
213
|
+
Stop a Transcode Session
|
|
214
|
+
"""
|
|
215
|
+
hook_ctx = HookContext(operation_id='stopTranscodeSession', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
216
|
+
request = operations.StopTranscodeSessionRequest(
|
|
217
|
+
session_key=session_key,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
221
|
+
|
|
222
|
+
url = utils.generate_url(operations.StopTranscodeSessionRequest, base_url, '/transcode/sessions/{sessionKey}', request, self.sdk_configuration.globals)
|
|
223
|
+
|
|
224
|
+
if callable(self.sdk_configuration.security):
|
|
225
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
226
|
+
else:
|
|
227
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
228
|
+
|
|
229
|
+
headers['Accept'] = 'application/json'
|
|
230
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
231
|
+
client = self.sdk_configuration.client
|
|
232
|
+
|
|
233
|
+
try:
|
|
234
|
+
req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
|
|
235
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
236
|
+
http_res = client.send(req)
|
|
237
|
+
except Exception as e:
|
|
238
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
239
|
+
if e is not None:
|
|
240
|
+
raise e
|
|
241
|
+
|
|
242
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
243
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
244
|
+
if e is not None:
|
|
245
|
+
raise e
|
|
246
|
+
if result is not None:
|
|
247
|
+
http_res = result
|
|
248
|
+
else:
|
|
249
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
res = operations.StopTranscodeSessionResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
254
|
+
|
|
255
|
+
if http_res.status_code == 204:
|
|
256
|
+
pass
|
|
257
|
+
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:
|
|
258
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
259
|
+
elif http_res.status_code == 401:
|
|
260
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
261
|
+
out = utils.unmarshal_json(http_res.text, errors.StopTranscodeSessionResponseBody)
|
|
262
|
+
out.raw_response = http_res
|
|
263
|
+
raise out
|
|
264
|
+
else:
|
|
265
|
+
content_type = http_res.headers.get('Content-Type')
|
|
266
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
267
|
+
else:
|
|
268
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
269
|
+
|
|
270
|
+
return res
|
|
271
|
+
|
|
272
|
+
|
plex_api/statistics.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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 Statistics:
|
|
11
|
+
r"""API Calls that perform operations with Plex Media Server Statistics"""
|
|
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_statistics(self, timespan: Optional[int] = None) -> operations.GetStatisticsResponse:
|
|
20
|
+
r"""Get Media Statistics
|
|
21
|
+
This will return the media statistics for the server
|
|
22
|
+
"""
|
|
23
|
+
hook_ctx = HookContext(operation_id='getStatistics', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
24
|
+
request = operations.GetStatisticsRequest(
|
|
25
|
+
timespan=timespan,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
29
|
+
|
|
30
|
+
url = base_url + '/statistics/media'
|
|
31
|
+
|
|
32
|
+
if callable(self.sdk_configuration.security):
|
|
33
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
34
|
+
else:
|
|
35
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
36
|
+
|
|
37
|
+
query_params = { **utils.get_query_params(operations.GetStatisticsRequest, request, self.sdk_configuration.globals), **query_params }
|
|
38
|
+
headers['Accept'] = 'application/json'
|
|
39
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
40
|
+
client = self.sdk_configuration.client
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
44
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
45
|
+
http_res = client.send(req)
|
|
46
|
+
except Exception as e:
|
|
47
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
48
|
+
if e is not None:
|
|
49
|
+
raise e
|
|
50
|
+
|
|
51
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
52
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
53
|
+
if e is not None:
|
|
54
|
+
raise e
|
|
55
|
+
if result is not None:
|
|
56
|
+
http_res = result
|
|
57
|
+
else:
|
|
58
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
res = operations.GetStatisticsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
63
|
+
|
|
64
|
+
if http_res.status_code == 200:
|
|
65
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
66
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetStatisticsResponseBody])
|
|
67
|
+
res.object = out
|
|
68
|
+
else:
|
|
69
|
+
content_type = http_res.headers.get('Content-Type')
|
|
70
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
71
|
+
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:
|
|
72
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
73
|
+
elif http_res.status_code == 401:
|
|
74
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
75
|
+
out = utils.unmarshal_json(http_res.text, errors.GetStatisticsResponseBody)
|
|
76
|
+
out.raw_response = http_res
|
|
77
|
+
raise out
|
|
78
|
+
else:
|
|
79
|
+
content_type = http_res.headers.get('Content-Type')
|
|
80
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
81
|
+
else:
|
|
82
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
83
|
+
|
|
84
|
+
return res
|
|
85
|
+
|
|
86
|
+
|
plex_api/updater.py
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
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 Updater:
|
|
11
|
+
r"""This describes the API for searching and applying updates to the Plex Media Server.
|
|
12
|
+
Updates to the status can be observed via the Event API.
|
|
13
|
+
"""
|
|
14
|
+
sdk_configuration: SDKConfiguration
|
|
15
|
+
|
|
16
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
|
17
|
+
self.sdk_configuration = sdk_config
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_update_status(self) -> operations.GetUpdateStatusResponse:
|
|
22
|
+
r"""Querying status of updates
|
|
23
|
+
Querying status of updates
|
|
24
|
+
"""
|
|
25
|
+
hook_ctx = HookContext(operation_id='getUpdateStatus', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
26
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
27
|
+
|
|
28
|
+
url = base_url + '/updater/status'
|
|
29
|
+
|
|
30
|
+
if callable(self.sdk_configuration.security):
|
|
31
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
32
|
+
else:
|
|
33
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
34
|
+
|
|
35
|
+
headers['Accept'] = 'application/json'
|
|
36
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
37
|
+
client = self.sdk_configuration.client
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
41
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
42
|
+
http_res = client.send(req)
|
|
43
|
+
except Exception as e:
|
|
44
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
45
|
+
if e is not None:
|
|
46
|
+
raise e
|
|
47
|
+
|
|
48
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
49
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
50
|
+
if e is not None:
|
|
51
|
+
raise e
|
|
52
|
+
if result is not None:
|
|
53
|
+
http_res = result
|
|
54
|
+
else:
|
|
55
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
res = operations.GetUpdateStatusResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
60
|
+
|
|
61
|
+
if http_res.status_code == 200:
|
|
62
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
63
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetUpdateStatusResponseBody])
|
|
64
|
+
res.object = out
|
|
65
|
+
else:
|
|
66
|
+
content_type = http_res.headers.get('Content-Type')
|
|
67
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
68
|
+
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:
|
|
69
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
70
|
+
elif http_res.status_code == 401:
|
|
71
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
72
|
+
out = utils.unmarshal_json(http_res.text, errors.GetUpdateStatusResponseBody)
|
|
73
|
+
out.raw_response = http_res
|
|
74
|
+
raise out
|
|
75
|
+
else:
|
|
76
|
+
content_type = http_res.headers.get('Content-Type')
|
|
77
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
78
|
+
else:
|
|
79
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
80
|
+
|
|
81
|
+
return res
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def check_for_updates(self, download: Optional[operations.Download] = None) -> operations.CheckForUpdatesResponse:
|
|
86
|
+
r"""Checking for updates
|
|
87
|
+
Checking for updates
|
|
88
|
+
"""
|
|
89
|
+
hook_ctx = HookContext(operation_id='checkForUpdates', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
90
|
+
request = operations.CheckForUpdatesRequest(
|
|
91
|
+
download=download,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
95
|
+
|
|
96
|
+
url = base_url + '/updater/check'
|
|
97
|
+
|
|
98
|
+
if callable(self.sdk_configuration.security):
|
|
99
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
100
|
+
else:
|
|
101
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
102
|
+
|
|
103
|
+
query_params = { **utils.get_query_params(operations.CheckForUpdatesRequest, request, self.sdk_configuration.globals), **query_params }
|
|
104
|
+
headers['Accept'] = 'application/json'
|
|
105
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
106
|
+
client = self.sdk_configuration.client
|
|
107
|
+
|
|
108
|
+
try:
|
|
109
|
+
req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
|
|
110
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
111
|
+
http_res = client.send(req)
|
|
112
|
+
except Exception as e:
|
|
113
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
114
|
+
if e is not None:
|
|
115
|
+
raise e
|
|
116
|
+
|
|
117
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
118
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
119
|
+
if e is not None:
|
|
120
|
+
raise e
|
|
121
|
+
if result is not None:
|
|
122
|
+
http_res = result
|
|
123
|
+
else:
|
|
124
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
res = operations.CheckForUpdatesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
129
|
+
|
|
130
|
+
if http_res.status_code == 200:
|
|
131
|
+
pass
|
|
132
|
+
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:
|
|
133
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
134
|
+
elif http_res.status_code == 401:
|
|
135
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
136
|
+
out = utils.unmarshal_json(http_res.text, errors.CheckForUpdatesResponseBody)
|
|
137
|
+
out.raw_response = http_res
|
|
138
|
+
raise out
|
|
139
|
+
else:
|
|
140
|
+
content_type = http_res.headers.get('Content-Type')
|
|
141
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
142
|
+
else:
|
|
143
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
144
|
+
|
|
145
|
+
return res
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def apply_updates(self, tonight: Optional[operations.Tonight] = None, skip: Optional[operations.Skip] = None) -> operations.ApplyUpdatesResponse:
|
|
150
|
+
r"""Apply Updates
|
|
151
|
+
Note that these two parameters are effectively mutually exclusive. The `tonight` parameter takes precedence and `skip` will be ignored if `tonight` is also passed
|
|
152
|
+
"""
|
|
153
|
+
hook_ctx = HookContext(operation_id='applyUpdates', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
154
|
+
request = operations.ApplyUpdatesRequest(
|
|
155
|
+
tonight=tonight,
|
|
156
|
+
skip=skip,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
160
|
+
|
|
161
|
+
url = base_url + '/updater/apply'
|
|
162
|
+
|
|
163
|
+
if callable(self.sdk_configuration.security):
|
|
164
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
165
|
+
else:
|
|
166
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
167
|
+
|
|
168
|
+
query_params = { **utils.get_query_params(operations.ApplyUpdatesRequest, request, self.sdk_configuration.globals), **query_params }
|
|
169
|
+
headers['Accept'] = 'application/json'
|
|
170
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
171
|
+
client = self.sdk_configuration.client
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
|
|
175
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
176
|
+
http_res = client.send(req)
|
|
177
|
+
except Exception as e:
|
|
178
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
179
|
+
if e is not None:
|
|
180
|
+
raise e
|
|
181
|
+
|
|
182
|
+
if utils.match_status_codes(['400','401','4XX','500','5XX'], http_res.status_code):
|
|
183
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
184
|
+
if e is not None:
|
|
185
|
+
raise e
|
|
186
|
+
if result is not None:
|
|
187
|
+
http_res = result
|
|
188
|
+
else:
|
|
189
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
res = operations.ApplyUpdatesResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
194
|
+
|
|
195
|
+
if http_res.status_code == 200:
|
|
196
|
+
pass
|
|
197
|
+
elif http_res.status_code == 400 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code == 500 or http_res.status_code >= 500 and http_res.status_code < 600:
|
|
198
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
199
|
+
elif http_res.status_code == 401:
|
|
200
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
201
|
+
out = utils.unmarshal_json(http_res.text, errors.ApplyUpdatesResponseBody)
|
|
202
|
+
out.raw_response = http_res
|
|
203
|
+
raise out
|
|
204
|
+
else:
|
|
205
|
+
content_type = http_res.headers.get('Content-Type')
|
|
206
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
207
|
+
else:
|
|
208
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
209
|
+
|
|
210
|
+
return res
|
|
211
|
+
|
|
212
|
+
|