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/playlists.py
ADDED
|
@@ -0,0 +1,629 @@
|
|
|
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 Playlists:
|
|
11
|
+
r"""Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as \\"all albums from 2017\\").
|
|
12
|
+
They can be organized in (optionally nesting) folders.
|
|
13
|
+
Retrieving a playlist, or its items, will trigger a refresh of its metadata.
|
|
14
|
+
This may cause the duration and number of items to change.
|
|
15
|
+
"""
|
|
16
|
+
sdk_configuration: SDKConfiguration
|
|
17
|
+
|
|
18
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
|
19
|
+
self.sdk_configuration = sdk_config
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def create_playlist(self, request: operations.CreatePlaylistRequest) -> operations.CreatePlaylistResponse:
|
|
24
|
+
r"""Create a Playlist
|
|
25
|
+
Create a new playlist. By default the playlist is blank. To create a playlist along with a first item, pass:
|
|
26
|
+
- `uri` - The content URI for what we're playing (e.g. `server://1234/com.plexapp.plugins.library/library/metadata/1`).
|
|
27
|
+
- `playQueueID` - To create a playlist from an existing play queue.
|
|
28
|
+
"""
|
|
29
|
+
hook_ctx = HookContext(operation_id='createPlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
30
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
31
|
+
|
|
32
|
+
url = base_url + '/playlists'
|
|
33
|
+
|
|
34
|
+
if callable(self.sdk_configuration.security):
|
|
35
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
36
|
+
else:
|
|
37
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
38
|
+
|
|
39
|
+
query_params = { **utils.get_query_params(operations.CreatePlaylistRequest, request, self.sdk_configuration.globals), **query_params }
|
|
40
|
+
headers['Accept'] = 'application/json'
|
|
41
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
42
|
+
client = self.sdk_configuration.client
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
|
|
46
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
47
|
+
http_res = client.send(req)
|
|
48
|
+
except Exception as e:
|
|
49
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
50
|
+
if e is not None:
|
|
51
|
+
raise e
|
|
52
|
+
|
|
53
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
54
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
55
|
+
if e is not None:
|
|
56
|
+
raise e
|
|
57
|
+
if result is not None:
|
|
58
|
+
http_res = result
|
|
59
|
+
else:
|
|
60
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
res = operations.CreatePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
65
|
+
|
|
66
|
+
if http_res.status_code == 200:
|
|
67
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
68
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.CreatePlaylistResponseBody])
|
|
69
|
+
res.object = out
|
|
70
|
+
else:
|
|
71
|
+
content_type = http_res.headers.get('Content-Type')
|
|
72
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
73
|
+
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:
|
|
74
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
75
|
+
elif http_res.status_code == 401:
|
|
76
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
77
|
+
out = utils.unmarshal_json(http_res.text, errors.CreatePlaylistResponseBody)
|
|
78
|
+
out.raw_response = http_res
|
|
79
|
+
raise out
|
|
80
|
+
else:
|
|
81
|
+
content_type = http_res.headers.get('Content-Type')
|
|
82
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
83
|
+
else:
|
|
84
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
85
|
+
|
|
86
|
+
return res
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def get_playlists(self, playlist_type: Optional[operations.PlaylistType] = None, smart: Optional[operations.QueryParamSmart] = None) -> operations.GetPlaylistsResponse:
|
|
91
|
+
r"""Get All Playlists
|
|
92
|
+
Get All Playlists given the specified filters.
|
|
93
|
+
"""
|
|
94
|
+
hook_ctx = HookContext(operation_id='getPlaylists', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
95
|
+
request = operations.GetPlaylistsRequest(
|
|
96
|
+
playlist_type=playlist_type,
|
|
97
|
+
smart=smart,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
101
|
+
|
|
102
|
+
url = base_url + '/playlists'
|
|
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.GetPlaylistsRequest, 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.GetPlaylistsResponse(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.GetPlaylistsResponseBody])
|
|
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.GetPlaylistsResponseBody)
|
|
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
|
+
|
|
159
|
+
|
|
160
|
+
def get_playlist(self, playlist_id: float) -> operations.GetPlaylistResponse:
|
|
161
|
+
r"""Retrieve Playlist
|
|
162
|
+
Gets detailed metadata for a playlist. A playlist for many purposes (rating, editing metadata, tagging), can be treated like a regular metadata item:
|
|
163
|
+
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.
|
|
164
|
+
"""
|
|
165
|
+
hook_ctx = HookContext(operation_id='getPlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
166
|
+
request = operations.GetPlaylistRequest(
|
|
167
|
+
playlist_id=playlist_id,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
171
|
+
|
|
172
|
+
url = utils.generate_url(operations.GetPlaylistRequest, base_url, '/playlists/{playlistID}', request, self.sdk_configuration.globals)
|
|
173
|
+
|
|
174
|
+
if callable(self.sdk_configuration.security):
|
|
175
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
176
|
+
else:
|
|
177
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
178
|
+
|
|
179
|
+
headers['Accept'] = 'application/json'
|
|
180
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
181
|
+
client = self.sdk_configuration.client
|
|
182
|
+
|
|
183
|
+
try:
|
|
184
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
185
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
186
|
+
http_res = client.send(req)
|
|
187
|
+
except Exception as e:
|
|
188
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
189
|
+
if e is not None:
|
|
190
|
+
raise e
|
|
191
|
+
|
|
192
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
193
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
194
|
+
if e is not None:
|
|
195
|
+
raise e
|
|
196
|
+
if result is not None:
|
|
197
|
+
http_res = result
|
|
198
|
+
else:
|
|
199
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
res = operations.GetPlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
204
|
+
|
|
205
|
+
if http_res.status_code == 200:
|
|
206
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
207
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistResponseBody])
|
|
208
|
+
res.object = out
|
|
209
|
+
else:
|
|
210
|
+
content_type = http_res.headers.get('Content-Type')
|
|
211
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
212
|
+
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:
|
|
213
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
214
|
+
elif http_res.status_code == 401:
|
|
215
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
216
|
+
out = utils.unmarshal_json(http_res.text, errors.GetPlaylistResponseBody)
|
|
217
|
+
out.raw_response = http_res
|
|
218
|
+
raise out
|
|
219
|
+
else:
|
|
220
|
+
content_type = http_res.headers.get('Content-Type')
|
|
221
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
222
|
+
else:
|
|
223
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
224
|
+
|
|
225
|
+
return res
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def delete_playlist(self, playlist_id: float) -> operations.DeletePlaylistResponse:
|
|
230
|
+
r"""Deletes a Playlist
|
|
231
|
+
This endpoint will delete a playlist
|
|
232
|
+
"""
|
|
233
|
+
hook_ctx = HookContext(operation_id='deletePlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
234
|
+
request = operations.DeletePlaylistRequest(
|
|
235
|
+
playlist_id=playlist_id,
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
239
|
+
|
|
240
|
+
url = utils.generate_url(operations.DeletePlaylistRequest, base_url, '/playlists/{playlistID}', request, self.sdk_configuration.globals)
|
|
241
|
+
|
|
242
|
+
if callable(self.sdk_configuration.security):
|
|
243
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
244
|
+
else:
|
|
245
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
246
|
+
|
|
247
|
+
headers['Accept'] = 'application/json'
|
|
248
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
249
|
+
client = self.sdk_configuration.client
|
|
250
|
+
|
|
251
|
+
try:
|
|
252
|
+
req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
|
|
253
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
254
|
+
http_res = client.send(req)
|
|
255
|
+
except Exception as e:
|
|
256
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
257
|
+
if e is not None:
|
|
258
|
+
raise e
|
|
259
|
+
|
|
260
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
261
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
262
|
+
if e is not None:
|
|
263
|
+
raise e
|
|
264
|
+
if result is not None:
|
|
265
|
+
http_res = result
|
|
266
|
+
else:
|
|
267
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
res = operations.DeletePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
272
|
+
|
|
273
|
+
if http_res.status_code == 200:
|
|
274
|
+
pass
|
|
275
|
+
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:
|
|
276
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
277
|
+
elif http_res.status_code == 401:
|
|
278
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
279
|
+
out = utils.unmarshal_json(http_res.text, errors.DeletePlaylistResponseBody)
|
|
280
|
+
out.raw_response = http_res
|
|
281
|
+
raise out
|
|
282
|
+
else:
|
|
283
|
+
content_type = http_res.headers.get('Content-Type')
|
|
284
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
285
|
+
else:
|
|
286
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
287
|
+
|
|
288
|
+
return res
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def update_playlist(self, playlist_id: float, title: Optional[str] = None, summary: Optional[str] = None) -> operations.UpdatePlaylistResponse:
|
|
293
|
+
r"""Update a Playlist
|
|
294
|
+
From PMS version 1.9.1 clients can also edit playlist metadata using this endpoint as they would via `PUT /library/metadata/{playlistID}`
|
|
295
|
+
"""
|
|
296
|
+
hook_ctx = HookContext(operation_id='updatePlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
297
|
+
request = operations.UpdatePlaylistRequest(
|
|
298
|
+
playlist_id=playlist_id,
|
|
299
|
+
title=title,
|
|
300
|
+
summary=summary,
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
304
|
+
|
|
305
|
+
url = utils.generate_url(operations.UpdatePlaylistRequest, base_url, '/playlists/{playlistID}', request, self.sdk_configuration.globals)
|
|
306
|
+
|
|
307
|
+
if callable(self.sdk_configuration.security):
|
|
308
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
309
|
+
else:
|
|
310
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
311
|
+
|
|
312
|
+
query_params = { **utils.get_query_params(operations.UpdatePlaylistRequest, request, self.sdk_configuration.globals), **query_params }
|
|
313
|
+
headers['Accept'] = 'application/json'
|
|
314
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
315
|
+
client = self.sdk_configuration.client
|
|
316
|
+
|
|
317
|
+
try:
|
|
318
|
+
req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
|
|
319
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
320
|
+
http_res = client.send(req)
|
|
321
|
+
except Exception as e:
|
|
322
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
323
|
+
if e is not None:
|
|
324
|
+
raise e
|
|
325
|
+
|
|
326
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
327
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
328
|
+
if e is not None:
|
|
329
|
+
raise e
|
|
330
|
+
if result is not None:
|
|
331
|
+
http_res = result
|
|
332
|
+
else:
|
|
333
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
res = operations.UpdatePlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
338
|
+
|
|
339
|
+
if http_res.status_code == 200:
|
|
340
|
+
pass
|
|
341
|
+
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:
|
|
342
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
343
|
+
elif http_res.status_code == 401:
|
|
344
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
345
|
+
out = utils.unmarshal_json(http_res.text, errors.UpdatePlaylistResponseBody)
|
|
346
|
+
out.raw_response = http_res
|
|
347
|
+
raise out
|
|
348
|
+
else:
|
|
349
|
+
content_type = http_res.headers.get('Content-Type')
|
|
350
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
351
|
+
else:
|
|
352
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
353
|
+
|
|
354
|
+
return res
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def get_playlist_contents(self, playlist_id: float, type_: float) -> operations.GetPlaylistContentsResponse:
|
|
359
|
+
r"""Retrieve Playlist Contents
|
|
360
|
+
Gets the contents of a playlist. Should be paged by clients via standard mechanisms.
|
|
361
|
+
By default leaves are returned (e.g. episodes, movies). In order to return other types you can use the `type` parameter.
|
|
362
|
+
For example, you could use this to display a list of recently added albums vis a smart playlist.
|
|
363
|
+
Note that for dumb playlists, items have a `playlistItemID` attribute which is used for deleting or moving items.
|
|
364
|
+
"""
|
|
365
|
+
hook_ctx = HookContext(operation_id='getPlaylistContents', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
366
|
+
request = operations.GetPlaylistContentsRequest(
|
|
367
|
+
playlist_id=playlist_id,
|
|
368
|
+
type=type_,
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
372
|
+
|
|
373
|
+
url = utils.generate_url(operations.GetPlaylistContentsRequest, base_url, '/playlists/{playlistID}/items', request, self.sdk_configuration.globals)
|
|
374
|
+
|
|
375
|
+
if callable(self.sdk_configuration.security):
|
|
376
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
377
|
+
else:
|
|
378
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
379
|
+
|
|
380
|
+
query_params = { **utils.get_query_params(operations.GetPlaylistContentsRequest, request, self.sdk_configuration.globals), **query_params }
|
|
381
|
+
headers['Accept'] = 'application/json'
|
|
382
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
383
|
+
client = self.sdk_configuration.client
|
|
384
|
+
|
|
385
|
+
try:
|
|
386
|
+
req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers))
|
|
387
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
388
|
+
http_res = client.send(req)
|
|
389
|
+
except Exception as e:
|
|
390
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
391
|
+
if e is not None:
|
|
392
|
+
raise e
|
|
393
|
+
|
|
394
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
395
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
396
|
+
if e is not None:
|
|
397
|
+
raise e
|
|
398
|
+
if result is not None:
|
|
399
|
+
http_res = result
|
|
400
|
+
else:
|
|
401
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
res = operations.GetPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
406
|
+
|
|
407
|
+
if http_res.status_code == 200:
|
|
408
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
409
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.GetPlaylistContentsResponseBody])
|
|
410
|
+
res.object = out
|
|
411
|
+
else:
|
|
412
|
+
content_type = http_res.headers.get('Content-Type')
|
|
413
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
414
|
+
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:
|
|
415
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
416
|
+
elif http_res.status_code == 401:
|
|
417
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
418
|
+
out = utils.unmarshal_json(http_res.text, errors.GetPlaylistContentsResponseBody)
|
|
419
|
+
out.raw_response = http_res
|
|
420
|
+
raise out
|
|
421
|
+
else:
|
|
422
|
+
content_type = http_res.headers.get('Content-Type')
|
|
423
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
424
|
+
else:
|
|
425
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
426
|
+
|
|
427
|
+
return res
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
def clear_playlist_contents(self, playlist_id: float) -> operations.ClearPlaylistContentsResponse:
|
|
432
|
+
r"""Delete Playlist Contents
|
|
433
|
+
Clears a playlist, only works with dumb playlists. Returns the playlist.
|
|
434
|
+
"""
|
|
435
|
+
hook_ctx = HookContext(operation_id='clearPlaylistContents', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
436
|
+
request = operations.ClearPlaylistContentsRequest(
|
|
437
|
+
playlist_id=playlist_id,
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
441
|
+
|
|
442
|
+
url = utils.generate_url(operations.ClearPlaylistContentsRequest, base_url, '/playlists/{playlistID}/items', request, self.sdk_configuration.globals)
|
|
443
|
+
|
|
444
|
+
if callable(self.sdk_configuration.security):
|
|
445
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
446
|
+
else:
|
|
447
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
448
|
+
|
|
449
|
+
headers['Accept'] = 'application/json'
|
|
450
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
451
|
+
client = self.sdk_configuration.client
|
|
452
|
+
|
|
453
|
+
try:
|
|
454
|
+
req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers))
|
|
455
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
456
|
+
http_res = client.send(req)
|
|
457
|
+
except Exception as e:
|
|
458
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
459
|
+
if e is not None:
|
|
460
|
+
raise e
|
|
461
|
+
|
|
462
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
463
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
464
|
+
if e is not None:
|
|
465
|
+
raise e
|
|
466
|
+
if result is not None:
|
|
467
|
+
http_res = result
|
|
468
|
+
else:
|
|
469
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
res = operations.ClearPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
474
|
+
|
|
475
|
+
if http_res.status_code == 200:
|
|
476
|
+
pass
|
|
477
|
+
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:
|
|
478
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
479
|
+
elif http_res.status_code == 401:
|
|
480
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
481
|
+
out = utils.unmarshal_json(http_res.text, errors.ClearPlaylistContentsResponseBody)
|
|
482
|
+
out.raw_response = http_res
|
|
483
|
+
raise out
|
|
484
|
+
else:
|
|
485
|
+
content_type = http_res.headers.get('Content-Type')
|
|
486
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
487
|
+
else:
|
|
488
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
489
|
+
|
|
490
|
+
return res
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def add_playlist_contents(self, playlist_id: float, uri: str, play_queue_id: Optional[float] = None) -> operations.AddPlaylistContentsResponse:
|
|
495
|
+
r"""Adding to a Playlist
|
|
496
|
+
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.
|
|
497
|
+
With a smart playlist, passing a new `uri` parameter replaces the rules for the playlist. Returns the playlist.
|
|
498
|
+
"""
|
|
499
|
+
hook_ctx = HookContext(operation_id='addPlaylistContents', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
500
|
+
request = operations.AddPlaylistContentsRequest(
|
|
501
|
+
playlist_id=playlist_id,
|
|
502
|
+
uri=uri,
|
|
503
|
+
play_queue_id=play_queue_id,
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
507
|
+
|
|
508
|
+
url = utils.generate_url(operations.AddPlaylistContentsRequest, base_url, '/playlists/{playlistID}/items', request, self.sdk_configuration.globals)
|
|
509
|
+
|
|
510
|
+
if callable(self.sdk_configuration.security):
|
|
511
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
512
|
+
else:
|
|
513
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
514
|
+
|
|
515
|
+
query_params = { **utils.get_query_params(operations.AddPlaylistContentsRequest, request, self.sdk_configuration.globals), **query_params }
|
|
516
|
+
headers['Accept'] = 'application/json'
|
|
517
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
518
|
+
client = self.sdk_configuration.client
|
|
519
|
+
|
|
520
|
+
try:
|
|
521
|
+
req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, headers=headers))
|
|
522
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
523
|
+
http_res = client.send(req)
|
|
524
|
+
except Exception as e:
|
|
525
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
526
|
+
if e is not None:
|
|
527
|
+
raise e
|
|
528
|
+
|
|
529
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
530
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
531
|
+
if e is not None:
|
|
532
|
+
raise e
|
|
533
|
+
if result is not None:
|
|
534
|
+
http_res = result
|
|
535
|
+
else:
|
|
536
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
res = operations.AddPlaylistContentsResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
541
|
+
|
|
542
|
+
if http_res.status_code == 200:
|
|
543
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
544
|
+
out = utils.unmarshal_json(http_res.text, Optional[operations.AddPlaylistContentsResponseBody])
|
|
545
|
+
res.object = out
|
|
546
|
+
else:
|
|
547
|
+
content_type = http_res.headers.get('Content-Type')
|
|
548
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
549
|
+
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:
|
|
550
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
551
|
+
elif http_res.status_code == 401:
|
|
552
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
553
|
+
out = utils.unmarshal_json(http_res.text, errors.AddPlaylistContentsResponseBody)
|
|
554
|
+
out.raw_response = http_res
|
|
555
|
+
raise out
|
|
556
|
+
else:
|
|
557
|
+
content_type = http_res.headers.get('Content-Type')
|
|
558
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
559
|
+
else:
|
|
560
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
561
|
+
|
|
562
|
+
return res
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
def upload_playlist(self, path: str, force: operations.Force) -> operations.UploadPlaylistResponse:
|
|
567
|
+
r"""Upload Playlist
|
|
568
|
+
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.
|
|
569
|
+
"""
|
|
570
|
+
hook_ctx = HookContext(operation_id='uploadPlaylist', oauth2_scopes=[], security_source=self.sdk_configuration.security)
|
|
571
|
+
request = operations.UploadPlaylistRequest(
|
|
572
|
+
path=path,
|
|
573
|
+
force=force,
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
|
|
577
|
+
|
|
578
|
+
url = base_url + '/playlists/upload'
|
|
579
|
+
|
|
580
|
+
if callable(self.sdk_configuration.security):
|
|
581
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security())
|
|
582
|
+
else:
|
|
583
|
+
headers, query_params = utils.get_security(self.sdk_configuration.security)
|
|
584
|
+
|
|
585
|
+
query_params = { **utils.get_query_params(operations.UploadPlaylistRequest, request, self.sdk_configuration.globals), **query_params }
|
|
586
|
+
headers['Accept'] = 'application/json'
|
|
587
|
+
headers['user-agent'] = self.sdk_configuration.user_agent
|
|
588
|
+
client = self.sdk_configuration.client
|
|
589
|
+
|
|
590
|
+
try:
|
|
591
|
+
req = client.prepare_request(requests_http.Request('POST', url, params=query_params, headers=headers))
|
|
592
|
+
req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req)
|
|
593
|
+
http_res = client.send(req)
|
|
594
|
+
except Exception as e:
|
|
595
|
+
_, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e)
|
|
596
|
+
if e is not None:
|
|
597
|
+
raise e
|
|
598
|
+
|
|
599
|
+
if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
|
|
600
|
+
result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
601
|
+
if e is not None:
|
|
602
|
+
raise e
|
|
603
|
+
if result is not None:
|
|
604
|
+
http_res = result
|
|
605
|
+
else:
|
|
606
|
+
http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
res = operations.UploadPlaylistResponse(status_code=http_res.status_code, content_type=http_res.headers.get('Content-Type') or '', raw_response=http_res)
|
|
611
|
+
|
|
612
|
+
if http_res.status_code == 200:
|
|
613
|
+
pass
|
|
614
|
+
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:
|
|
615
|
+
raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res)
|
|
616
|
+
elif http_res.status_code == 401:
|
|
617
|
+
if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'):
|
|
618
|
+
out = utils.unmarshal_json(http_res.text, errors.UploadPlaylistResponseBody)
|
|
619
|
+
out.raw_response = http_res
|
|
620
|
+
raise out
|
|
621
|
+
else:
|
|
622
|
+
content_type = http_res.headers.get('Content-Type')
|
|
623
|
+
raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res)
|
|
624
|
+
else:
|
|
625
|
+
raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res)
|
|
626
|
+
|
|
627
|
+
return res
|
|
628
|
+
|
|
629
|
+
|